mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Switches credentials to use GITHUB_TOKEN (#13)
* Adding x-access-token trigger * Switch * README * Giving this a test * Pusher * ccc * Update entrypoint.sh * t * Another check * More changes to the readme * Testing a curl? * Update entrypoint.sh * Update entrypoint.sh * Update entrypoint.sh * Update entrypoint.sh * GitHub action metadata * More changes * Update README.md * Update entrypoint.sh * Update README.md * Update README.md * Update README.md * Update README.md
This commit is contained in:
parent
2641b391f2
commit
dc639e5086
@ -22,7 +22,7 @@ jobs:
|
||||
- name: Build and Deploy
|
||||
uses: JamesIves/github-pages-deploy-action@master
|
||||
env:
|
||||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BASE_BRANCH: master # The branch the action should deploy from.
|
||||
BRANCH: gh-pages # The branch the action should deploy to.
|
||||
FOLDER: build # The folder the action should deploy.
|
||||
@ -46,7 +46,8 @@ Below you'll find a description of what each option does.
|
||||
|
||||
| Key | Value Information | Type | Required |
|
||||
| ------------- | ------------- | ------------- | ------------- |
|
||||
| `ACCESS_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with a GitHub personal access token with read/write permissions. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). This **should be stored as a secret.** | `secrets` | **Yes** |
|
||||
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repositories provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. Only required if an access token is **not** provided. **Please note there is currently an issue affecting the use of this token, [you can learn more here](https://github.com/JamesIves/github-pages-deploy-action/issues/5)**. | `secrets` | **Yes** |
|
||||
| `ACCESS_TOKEN` | Depending on the repository permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets` | **No** |
|
||||
| `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | `env` | **Yes** |
|
||||
| `FOLDER` | The folder in your repository that you want to deploy. If your build script compiles into a directory named `build` you'd put it here. **Folder paths cannot have a leading `/` or `./`**. | `env` | **Yes** |
|
||||
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to `master`. | `env` | **No** |
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$ACCESS_TOKEN" ]
|
||||
if [ -z "$ACCESS_TOKEN" ] && [ -z "$GITHUB_TOKEN" ]
|
||||
then
|
||||
echo "You must provide the action with a GitHub Personal Access Token secret in order to deploy."
|
||||
echo "You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -54,7 +54,7 @@ git config --global user.email "${COMMIT_EMAIL}" && \
|
||||
git config --global user.name "${COMMIT_NAME}" && \
|
||||
|
||||
## Initializes the repository path using the access token.
|
||||
REPOSITORY_PATH="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
|
||||
REPOSITORY_PATH="https://${ACCESS_TOKEN:-"x-access-token:$GITHUB_TOKEN"}@github.com/${GITHUB_REPOSITORY}.git" && \
|
||||
|
||||
# Checks to see if the remote exists prior to deploying.
|
||||
# If the branch doesn't exist it gets created here as an orphan.
|
||||
@ -88,4 +88,5 @@ git add -f $FOLDER && \
|
||||
|
||||
git commit -m "Deploying to ${BRANCH} from ${BASE_BRANCH:-master} ${GITHUB_SHA}" --quiet && \
|
||||
git push $REPOSITORY_PATH `git subtree split --prefix $FOLDER ${BASE_BRANCH:-master}`:$BRANCH --force && \
|
||||
|
||||
echo "Deployment succesful!"
|
||||
|
Loading…
Reference in New Issue
Block a user