Access tokenizing things

This commit is contained in:
James Ives 2019-03-03 15:14:05 -05:00
parent da815add71
commit 5d5f1c0870
2 changed files with 8 additions and 3 deletions

View File

@ -26,16 +26,17 @@ action "Deploy to Github Pages" {
COMMIT_EMAIL = "github-pages-deployer@jamesives.dev"
COMMIT_NAME = "Github Pages Deployer"
}
secrets = ["GITHUB_TOKEN"]
secrets = ["ACCESS_TOKEN"]
}
```
## Configuration 📁
The `env` portion of the workflow must be configured before the action will work. Below you'll find a description of each one does.
The `secrets` and `env` portion of the workflow must be configured before the action will work. Below you'll find a description of each one does.
| Key | Value Information | Required |
| ------------- | ------------- | ------------- |
| `ACCESS_TOKEN` | You must provide the action with a GitHub personal access token in order to trigger GitHub pages to rebuild your page. This is set in the `secrets` area of the workflow editor. | **No** |
| `BUILD_SCRIPT` | If you require a build script to compile your code prior to pushing it you can add the script here. The Docker container which powers the action runs Node which means `npm` commands are valid. If you're using a static site generator I'd suggest building the code prior to pushing it. | **No** |
| `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | **Yes** |
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to `master`. | **No** |

View File

@ -11,6 +11,9 @@ then
exit 1
fi
## Initializes Variables
REPOSITORY_PATH="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
# Installs Git.
apt-get update && \
apt-get install -y git && \
@ -19,6 +22,7 @@ apt-get install -y git && \
cd $GITHUB_WORKSPACE && \
# Configures Git and checks out the base branch.
git init && \
git config --global user.email "${COMMIT_EMAIL:-gh-pages-deploy@jives.dev}" && \
git config --global user.name "${COMMIT_NAME:-Github Pages Deploy}" && \
git checkout "${BASE_BRANCH:-master}" && \
@ -30,5 +34,5 @@ eval "$BUILD_SCRIPT"
# Commits the data to Github.
git add -f $FOLDER && \
git commit -m "Deploying $(date +"%T")" && \
git push origin `git subtree split --prefix $FOLDER master`:$BRANCH --force
git push --force $REPOSITORY_PATH `git subtree split --prefix $FOLDER master`:$BRANCH