diff --git a/README.md b/README.md index 253fe3f..454b482 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,9 @@ for all inputs. You must have a single wiki page available from the beginning. It can be blank, but there must be at least one page that exists. You must also have a directory where all your wiki files will -be located (the default directory is "wiki/"). +be located (the default directory is "wiki/"). To include the +mandatory homepage, have a file in your wiki/ directory +called Home.md or with any other extension (e.g. rst). ```yaml name: Deploy Wiki @@ -46,13 +48,14 @@ jobs: # Make sure you have that / at the end. We use rsync # WIKI_DIR's default is wiki/ WIKI_DIR: wiki/ - GH_PAT: ${{ secrets.GH_PAT }} + GH_PAT: ${{ secrets.GITHUB_TOKEN }} GH_MAIL: ${{ secrets.YOUR_EMAIL }} GH_NAME: ${{ github.repository_owner }} ``` -You're going to need a Personal Access Token with the minimal scopes of -[seen here.](https://github.com/settings/tokens/new?scopes=repo&description=wiki%20page%20creator%20token) +If you plan on having a different repository host your wiki +directory, you're going to need a Personal Access Token instead of the `GITHUB_TOKEN` +with the minimal scopes [seen here.](https://github.com/settings/tokens/new?scopes=repo&description=wiki%20page%20creator%20token) --- This intended usage was to avoid hosting a private ReadTheDocs diff --git a/action.yml b/action.yml index c3e8d8b..da9b6b7 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ inputs: description: 'Directory to rsync files to the wiki.' required: false default: 'wiki/' - GH_PAT: + GH_TOKEN: description: 'The GitHub Personal Access Token for this action to use' required: true GH_MAIL: @@ -19,7 +19,7 @@ inputs: description: 'The username associated with the token.' required: true REPO: - description: 'The target repository.' + description: 'The target repository. Default is the current repo.' required: false WIKI_PUSH_MESSAGE: description: 'The commit message for the wiki commit. Default is the commit to actual repository.' diff --git a/entrypoint.sh b/entrypoint.sh index 945c046..4e71e01 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,9 @@ TEMP_CLONE_FOLDER="temp_wiki_4567129308192764578126573891723968" +if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN ENV is missing. Use $\{{ secrets.GITHUB_TOKEN }} or a PAT if your wiki repo is different from your current repo." + if [ -z "$GH_MAIL" ]; then echo "GH_MAIL ENV is missing. Use the email for a user that can push to this repository." exit 1 @@ -15,13 +18,6 @@ fi if [ -z "$REPO" ]; then echo "REPO ENV is missing. Using the current one." REPO=$GITHUB_REPOSITORY -else - if [ -z "$REPO" != "$GITHUB_REPOSITORY"]; then - if [ -z "$GITHUB_TOKEN" == "$GH_PAT"]; then - echo "You must use a Personal Access Token to write to the wiki of a different repository." - exit 1 - fi - fi fi if [ -z "$WIKI_DIR" ]; then @@ -37,19 +33,18 @@ git init # Setup credentials git config user.name $GH_NAME git config user.email $GH_MAIL -credentials=${GH_PAT:-$GITHUB_TOKEN} -git pull https://$credentials@github.com/$REPO.wiki.git +git pull https://$GH_TOKEN@github.com/$REPO.wiki.git cd .. # Get commit message if [ -z "$WIKI_PUSH_MESSAGE" ]; then - echo "WIKI_PUSH_MESSAGE ENV is missing, using the commit's." message=$(git log -1 --format=%B) else message=$WIKI_PUSH_MESSAGE fi -echo "Message: $message" +echo "Message:" +echo $message echo "Copying files to Wiki" rsync -av $WIKI_DIR $TEMP_CLONE_FOLDER/ --exclude $TEMP_CLONE_FOLDER --exclude .git --delete @@ -57,5 +52,4 @@ echo "Pushing to Wiki" cd $TEMP_CLONE_FOLDER git add . git commit -m "$message" -echo https://$credentials@github.com/$REPO.wiki.git -git push --set-upstream https://$credentials@github.com/$REPO.wiki.git master +git push --set-upstream https://$GH_TOKEN@github.com/$REPO.wiki.git master