Skip to content

Commit

Permalink
Fix/wiki not initialized issue (#50)
Browse files Browse the repository at this point in the history
* Adds check for faild cloning and improves docs

* Adds error and exit 1 for push as well
  • Loading branch information
frederikheld authored Dec 12, 2020
1 parent bb08758 commit 6c13a98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ For rendering, it uses an instance of the [PlantUML Java app](https://plantuml.c
## Usage

First you need to create an authentication token that gives this action access to your wiki. This is neccessary since `${{ secrets.GITHUB_TOKEN }}`, which is automatically available within workflows, doesn't work with the wiki.
First make sure that your wiki is initalized. This means that you need to create at least one page in the wiki before this action can push the rendered diagrams to it. Otherwise the action will fail.

Then you need to create an authentication token that gives this action access to your wiki. This is neccessary since `${{ secrets.GITHUB_TOKEN }}`, which is automatically available within workflows, doesn't work with the wiki.

Follow [this documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) to create the token. Then follow [this documentation](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) to add the secret to your organization. Name the secret `WIKI_TOKEN`.

Expand Down
9 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ rm -r "${GITHUB_WORKSPACE}/artifacts_repo"

echo "=> Cloning wiki repository ..."
git clone $artifacts_repo "${GITHUB_WORKSPACE}/artifacts_repo"
if [ $? -gt 0 ]; then
echo " ERROR: Could not clone repo."
echo " Note: you need to initialize the wiki by creating at least one page before you can use this action!"
exit 1
fi

echo "=> Moving generated files to /${artifacts_upload_dir} in wiki repo ..."
mkdir -p "${GITHUB_WORKSPACE}/artifacts_repo/${artifacts_upload_dir}"
Expand All @@ -85,6 +90,10 @@ git add .
if git commit -m"Auto-generated PlantUML diagrams"; then
echo "=> Pushing artifacts ..."
git push
if [ $? -gt 0 ]; then
echo " ERROR: Could not push to repo."
exit 1
fi
else
echo "(i) Nothing changed since previous build. The wiki is already up to date and therefore nothing is being pushed."
fi
Expand Down

0 comments on commit 6c13a98

Please sign in to comment.