Skip to content

Commit acbed15

Browse files
authored
feat: configure github_token defaults and document required permissions (#279)
Update the 'preview' workflow to test the default value (can only be tested when PR are created from the main repo).
1 parent 4232571 commit acbed15

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.github/workflows/preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
id: preview_action
3232
name: test afc163/surge-preview
3333
with:
34+
# test the default 'github_token' value here
3435
surge_token: ${{ secrets.SURGE_TOKEN }}
35-
github_token: ${{ secrets.GITHUB_TOKEN }}
3636
teardown: 'true'
3737
dist: public/preview2
3838
build: |

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ on: [pull_request]
3030
jobs:
3131
preview:
3232
runs-on: ubuntu-latest
33+
permissions:
34+
pull-requests: write # allow surge-preview to create/update PR comments
3335
steps:
3436
- uses: actions/checkout@v2
3537
- uses: afc163/surge-preview@v1
3638
id: preview_step
3739
with:
3840
surge_token: ${{ secrets.SURGE_TOKEN }}
39-
github_token: ${{ secrets.GITHUB_TOKEN }}
4041
dist: public
4142
build: |
4243
npm install
@@ -54,6 +55,9 @@ name: 🔂 Surge PR Preview
5455
5556
on: [pull_request]
5657
58+
permissions:
59+
pull-requests: write # allow surge-preview to create/update PR comments
60+
5761
jobs:
5862
preview-job-1:
5963
runs-on: ubuntu-latest
@@ -62,7 +66,6 @@ jobs:
6266
- uses: afc163/surge-preview@v1
6367
with:
6468
surge_token: ${{ secrets.SURGE_TOKEN }}
65-
github_token: ${{ secrets.GITHUB_TOKEN }}
6669
dist: public
6770
build: |
6871
npm install
@@ -74,7 +77,6 @@ jobs:
7477
- uses: afc163/surge-preview@v1
7578
with:
7679
surge_token: ${{ secrets.SURGE_TOKEN }}
77-
github_token: ${{ secrets.GITHUB_TOKEN }}
7880
dist: public
7981
build: |
8082
npm install
@@ -102,12 +104,13 @@ on:
102104
jobs:
103105
preview:
104106
runs-on: ubuntu-latest
107+
permissions:
108+
pull-requests: write # allow surge-preview to create/update PR comments
105109
steps:
106110
- uses: actions/checkout@v2
107111
- uses: afc163/surge-preview@v1
108112
with:
109113
surge_token: ${{ secrets.SURGE_TOKEN }}
110-
github_token: ${{ secrets.GITHUB_TOKEN }}
111114
dist: public
112115
teardown: 'true'
113116
build: |
@@ -118,7 +121,7 @@ jobs:
118121
### Inputs
119122

120123
- `surge_token`: [Getting your Surge token](https://surge.sh/help/integrating-with-circleci).
121-
- `github_token`: `secrets.GITHUB_TOKEN`.
124+
- `github_token`: Defaults: [`github.token`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow). It is used to create Pull Request comment, so it requires the `pull-requests` permission set to `write` permission. Possible value: `secrets.GITHUB_TOKEN`.
122125
- `build`: build scripts to run before deploy.
123126
- `dist`: dist folder deployed to [surge.sh](https://surge.sh/).
124127
- `failOnError`: Set `failed` if a deployment throws error, defaults to `false`.

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inputs:
88
github_token:
99
description: 'github token'
1010
required: true
11+
default: ${{ github.token }}
1112
build:
1213
description: 'build scripts'
1314
default: |

0 commit comments

Comments
 (0)