Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default github_token to github.token #624

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 5 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ The next example step will deploy `./public` directory to the remote `gh-pages`
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

For newbies of GitHub Actions:
Note that the `GITHUB_TOKEN` is **NOT** a personal access token.
A GitHub Actions runner automatically creates a `GITHUB_TOKEN` secret to authenticate in your workflow.
So, you can start to deploy immediately without any configuration.



## Supported Tokens
Expand Down Expand Up @@ -164,7 +158,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

Expand All @@ -182,9 +175,10 @@ jobs:

### ⭐️ Set Runner's Access Token `github_token`

**This option is for `GITHUB_TOKEN`, not a personal access token.**

A GitHub Actions runner automatically creates a `GITHUB_TOKEN` secret to use in your workflow. You can use the `GITHUB_TOKEN` to authenticate in a workflow run.
For newbies of GitHub Actions:
Note that this option is for `GITHUB_TOKEN`, **NOT** a personal access token.
A GitHub Actions runner automatically creates a `GITHUB_TOKEN` secret to authenticate in your workflow.
So, you can start to deploy immediately without any configuration.

```yaml
- name: Deploy
Expand All @@ -194,7 +188,7 @@ A GitHub Actions runner automatically creates a `GITHUB_TOKEN` secret to use in
publish_dir: ./public
```

For more details about `GITHUB_TOKEN`: [Authenticating with the GITHUB_TOKEN - GitHub Help](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
For more details about `GITHUB_TOKEN`: [Authenticating with the GITHUB_TOKEN - GitHub Help](https://docs.github.com/en/actions/reference/authentication-in-a-workflow)

### ⭐️ Set SSH Private Key `deploy_key`

Expand Down Expand Up @@ -229,7 +223,6 @@ The default is `gh-pages`.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: your-branch # default: gh-pages
```

Expand All @@ -241,7 +234,6 @@ A source directory to deploy to GitHub Pages. The default is `public`.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out # default: public
```

Expand All @@ -256,7 +248,6 @@ A destination subdirectory on a publishing branch. The default is empty.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: subdir
```

Expand All @@ -273,7 +264,6 @@ Values should be split with a comma.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
exclude_assets: '.github,exclude-file1,exclude-file2'
```

Expand All @@ -283,9 +273,6 @@ Set `exclude_assets` to empty for including the `.github` directory to deploymen
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # Recommended for this usage
# personal_token: ${{ secrets.PERSONAL_TOKEN }} # An alternative
# github_token: ${{ secrets.GITHUB_TOKEN }} # This does not work for this usage
exclude_assets: ''
```

Expand All @@ -295,7 +282,6 @@ The `exclude_assets` option supports glob patterns.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
exclude_assets: '.github,exclude-file.txt,exclude-dir/**.txt'
```

Expand All @@ -310,7 +296,6 @@ For more details about the `CNAME` file, read the official documentation: [Manag
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
cname: github.com
```
Expand All @@ -330,7 +315,6 @@ Bypassing Jekyll makes the deployment faster and is necessary if you are deployi
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
enable_jekyll: true
```
Expand All @@ -347,7 +331,6 @@ For example:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
allow_empty_commit: true
```
Expand All @@ -367,7 +350,6 @@ For example:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true
```
Expand Down Expand Up @@ -413,7 +395,6 @@ This allows you to make your publish branch with only the latest commit.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: true
```
Expand All @@ -427,7 +408,6 @@ A commit is always created with the same user.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
Expand All @@ -444,7 +424,6 @@ When we create a commit with a message `docs: Update some post`, a deployment co
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
commit_message: ${{ github.event.head_commit.message }}
```
Expand All @@ -458,7 +437,6 @@ use the `full_commit_message` option instead of the `commit_message` option.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
full_commit_message: ${{ github.event.head_commit.message }}
```
Expand Down Expand Up @@ -498,7 +476,6 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
Expand Down Expand Up @@ -674,7 +651,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

Expand Down Expand Up @@ -724,7 +700,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

Expand Down Expand Up @@ -779,7 +754,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
```

Expand Down Expand Up @@ -830,7 +804,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
```

Expand Down Expand Up @@ -889,7 +862,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
```

Expand Down Expand Up @@ -951,7 +923,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
```

Expand Down Expand Up @@ -992,7 +963,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book
```

Expand Down Expand Up @@ -1036,7 +1006,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
```

Expand Down Expand Up @@ -1085,7 +1054,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

Expand Down Expand Up @@ -1115,7 +1083,6 @@ jobs:
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./
allow_empty_commit: true
enable_jekyll: true
Expand Down Expand Up @@ -1171,7 +1138,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./Output
```

Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ inputs:
github_token:
description: 'Set a generated GITHUB_TOKEN for pushing to the remote branch.'
required: false
default: ${{ github.token }}
personal_token:
description: 'Set a personal access token for pushing to the remote branch.'
required: false
Expand Down
4 changes: 2 additions & 2 deletions src/set-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export async function setTokens(inps: Inputs): Promise<string> {
);
if (inps.DeployKey) {
return setSSHKey(inps, publishRepo);
} else if (inps.PersonalToken) {
return setPersonalToken(inps.PersonalToken, publishRepo);
} else if (inps.GithubToken) {
const context = github.context;
const ref = context.ref;
Expand All @@ -133,8 +135,6 @@ export async function setTokens(inps: Inputs): Promise<string> {
ref,
eventName
);
} else if (inps.PersonalToken) {
return setPersonalToken(inps.PersonalToken, publishRepo);
} else {
throw new Error('not found deploy key or tokens');
}
Expand Down