From 0e95a6165ecb7f01aef7d8660fb72d5db1326a37 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 1 Sep 2019 07:01:38 +0200 Subject: [PATCH] Limitation using GITHUB_TOKEN --- README.md | 18 +++++++++++++++++- entrypoint.sh | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbeca18..35c6294 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,27 @@ Following inputs can be used as `step.with` keys ### environment variables -The following are *required* as `step.env` keys +Following environment variables can be used as `step.env` keys | Name | Description | |----------------|--------------------------------------| | `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets`| +| `GITHUB_PAT` | [Personal Access Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) (see Limitation section below)| + +## :warning: Limitation + +Currently, `GITHUB_TOKEN` does not suffice to trigger a page build on a **public repository** (propagate content to the GitHub content-delivery network). You must therefore create a custom [Personal Access Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) and use it through the `GITHUB_PAT` environment variable: + +```yaml +- name: Deploy + if: success() + uses: crazy-max/ghaction-github-pages@master + with: + target_branch: gh-pages + build_dir: public + env: + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} +``` ## 🤝 How can I help ? diff --git a/entrypoint.sh b/entrypoint.sh index 18e169e..0a8e572 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,7 +21,7 @@ git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" git add . git commit --allow-empty -m 'Deploy to GitHub pages' -git push --force --quiet "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "master:$TARGET_BRANCH" +git push --force --quiet https://${GITHUB_PAT:-"x-access-token:$GITHUB_TOKEN"}@github.com/${GITHUB_REPOSITORY}.git master:$TARGET_BRANCH rm -rf .git cd "$GITHUB_WORKSPACE"