Skip to content

Commit

Permalink
Mark gh_pages_token as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
EdricChan03 committed Feb 15, 2020
1 parent a0bde56 commit 63c6ec9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ See [`action.yml`](./action.yml) for a list of all supported inputs.

### Secrets used

This script requires the following secrets:
This script needs the following secrets:

Name | Description | Allowed values
---|---|---
`GITHUB_TOKEN` | Specifies the GitHub installation token. | A valid GitHub installation token. _(Note: GitHub already creates one for you by default - you just need to manually specify this token in your workflow file.)_
`GH_PAGES_TOKEN` | Specifies the personal access token to use to request a build request **(required)** | No default | A valid personal access token (create one [here](https://github.com/settings/tokens/new?scopes=public_repo,repo_deployment&description=Token%20for%20Deploy%20GitHub%20Pages%20GitHub%20Action) with the scopes `public_repo` and `repo_deployment` enabled) |
`GH_PAGES_TOKEN` | Specifies the personal access token to use to request a build request **(~~required~~ optional - no longer required as of 15 Feb 2020 - see this [GitHub Community post](https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/46519/highlight/true#M6551) and [#13](https://github.com/EdricChan03/action-build-deploy-ghpages/issues/13) for more info)** | A valid personal access token (create one [here](https://github.com/settings/tokens/new?scopes=public_repo,repo_deployment&description=Token%20for%20Deploy%20GitHub%20Pages%20GitHub%20Action) with the scopes `public_repo` and `repo_deployment` enabled)

### Examples

Expand All @@ -27,7 +27,7 @@ steps:
- uses: EdricChan03/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }}
# gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }} No longer needed - see https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/46519/highlight/true#M6551 for more info
```

Alternatively, you can target the latest `v2` version of the Action:
Expand All @@ -38,7 +38,7 @@ steps:
- uses: EdricChan03/action-build-deploy-ghpages@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }}
# gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }}
```

#### Environment variables (`v1`)
Expand All @@ -51,7 +51,7 @@ steps:
- uses: EdricChan03/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
# GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
OVERRIDE_GH_PAGES_BRANCH: 'true'
# ...
```
Expand All @@ -66,7 +66,7 @@ steps:
- uses: EdricChan03/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # Note: You don't have to create this secret - GitHub already does that for you (This input does not have a default value - you have to supply this yourself)
gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }} # Note: You have to create this yourself - see the "Secrets used" section above for more info (This input does not have a default value - you have to supply this yourself)
# gh_pages_token: ${{ secrets.GH_PAGES_TOKEN }} # Note: You have to create this yourself - see the "Secrets used" section above for more info (This input does not have a default value - you have to supply this yourself) (As of 15 Feb 2020, this is no longer needed - see https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/46519/highlight/true#M6551)
gh_pages_branch: 'gh-pages' # The GitHub Pages branch to deploy the site to
gh_pages_dist_folder: '_site' # The folder to build the site to
gh_pages_commit_message: 'Deploy commit $GITHUB_SHA\n\nAutodeployed using $GITHUB_ACTION in $GITHUB_WORKFLOW' # The commit message to use when deploying the site
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ inputs:
description: 'The GitHub installation token.'
required: true
gh_pages_token:
description: 'The token used for triggering a deploy request.'
required: true
description: 'The token used for triggering a deploy request. (This is no longer needed - see https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/46519/highlight/true#M6551)'
required: false
gh_pages_branch:
description: 'The branch to deploy the Jekyll site to.'
default: 'gh-pages'
Expand Down
13 changes: 10 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ fi
GH_PAGES_COMMIT_MESSAGE=${INPUT_GH_PAGES_COMMIT_MESSAGE:-${GH_PAGES_COMMIT_MESSAGE:-"Deploy commit $GITHUB_SHA\n\nAutodeployed using $GITHUB_ACTION in $GITHUB_WORKFLOW"}}

# GitHub Pages token for deploying
# Note: This is no longer needed - see
# https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/46519/highlight/true#M6551
# for more info.
GH_PAGES_TOKEN=${INPUT_GH_PAGES_TOKEN:-$GH_PAGES_TOKEN}

# GitHub token
Expand Down Expand Up @@ -143,11 +146,15 @@ if [[ -n "$GH_PAGES_COMMIT_POST_COMMANDS" ]]; then
eval "$GH_PAGES_COMMIT_POST_COMMANDS"
fi

echo "Requesting build request for deployed build..."
if [[ -n "$GH_PAGES_TOKEN" ]]; then
echo "Requesting build request for deployed build..."

curl -X POST -u "$GITHUB_ACTOR":"$GH_PAGES_TOKEN" -H "Accept: application/vnd.github.mister-fantastic-preview+json" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds"
curl -X POST -u "$GITHUB_ACTOR":"$GH_PAGES_TOKEN" -H "Accept: application/vnd.github.mister-fantastic-preview+json" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds"

echo "Successfully requested build request!"
echo "Successfully requested build request!"
else
echo "Skipping build request for deployed build as GH_PAGES_TOKEN was not specified."
fi

cd ..

Expand Down

0 comments on commit 63c6ec9

Please sign in to comment.