File tree Expand file tree Collapse file tree 8 files changed +49
-11
lines changed Expand file tree Collapse file tree 8 files changed +49
-11
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ name: Create terraform plan
5151
5252on : [pull_request]
5353
54+ permissions :
55+ contents : read
56+ pull-requests : write
57+
5458jobs :
5559 plan :
5660 runs-on : ubuntu-latest
7781 branches :
7882 - main
7983
84+ permissions :
85+ contents : read
86+ pull-requests : write
87+
8088jobs :
8189 apply :
8290 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 55 branches :
66 - main
77
8+ permissions :
9+ contents : read
10+ pull-requests : write
11+
812jobs :
913 plan :
1014 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ name: Create terraform plan
33on :
44 - pull_request
55
6+ permissions :
7+ contents : read
8+ pull-requests : write
9+
610jobs :
711 plan :
812 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ name: Validate changes
22
33on :
44 push :
5- branches :
6- - ' ! main'
5+ branches-ignore :
6+ - ' main'
77
88jobs :
99 fmt-check :
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ RUN apt-get update \
2727 wget \
2828 gpg \
2929 gpg-agent \
30- dirmngr \
30+ dirmngr \
3131 && rm -rf /var/lib/apt/lists/*
3232
3333RUN mkdir -p $TF_PLUGIN_CACHE_DIR
Original file line number Diff line number Diff line change @@ -76,6 +76,12 @@ function setup() {
7676 exit 1
7777 fi
7878
79+ if [[ ! -v TERRAFORM_ACTIONS_GITHUB_TOKEN ]]; then
80+ if [[ -v GITHUB_TOKEN ]]; then
81+ export TERRAFORM_ACTIONS_GITHUB_TOKEN=" $GITHUB_TOKEN "
82+ fi
83+ fi
84+
7985 if ! github_comment_react +1 2> " $STEP_TMP_DIR /github_comment_react.stderr" ; then
8086 debug_file " $STEP_TMP_DIR /github_comment_react.stderr"
8187 fi
@@ -102,12 +108,6 @@ function setup() {
102108
103109 detect-tfmask
104110
105- if [[ ! -v TERRAFORM_ACTIONS_GITHUB_TOKEN ]]; then
106- if [[ -v GITHUB_TOKEN ]]; then
107- export TERRAFORM_ACTIONS_GITHUB_TOKEN=" $GITHUB_TOKEN "
108- fi
109- fi
110-
111111 execute_run_commands
112112}
113113
Original file line number Diff line number Diff line change @@ -278,7 +278,8 @@ These input values must be the same as any `terraform-plan` for the same configu
278278 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
279279 ` ` `
280280
281- The token provided by GitHub Actions will work with the default permissions.
281+ The token provided by GitHub Actions has default permissions at GitHub's whim. You can see what it is for your repo under the repo settings.
282+
282283 The minimum permissions are `pull-requests : write`.
283284 It will also likely need `contents : read` so the job can checkout the repo.
284285
401402 branches:
402403 - main
403404
405+ permissions:
406+ contents: read
407+ pull-requests: write
408+
404409jobs:
405410 apply:
406411 runs-on: ubuntu-latest
516521 branches:
517522 - main
518523
524+ permissions:
525+ contents: read
526+ pull-requests: write
527+
519528jobs:
520529 plan:
521530 runs-on: ubuntu-latest
Original file line number Diff line number Diff line change @@ -195,7 +195,8 @@ The [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
195195 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196196 ` ` `
197197
198- The token provided by GitHub Actions will work with the default permissions.
198+ The token provided by GitHub Actions has default permissions at GitHub's whim. You can see what it is for your repo under the repo settings.
199+
199200 The minimum permissions are `pull-requests : write`.
200201 It will also likely need `contents : read` so the job can checkout the repo.
201202
@@ -385,6 +386,10 @@ name: PR Plan
385386
386387on: [pull_request]
387388
389+ permissions:
390+ contents: read
391+ pull-requests: write
392+
388393jobs:
389394 plan:
390395 runs-on: ubuntu-latest
@@ -419,6 +424,10 @@ env:
419424 TERRAFORM_CLOUD_TOKENS: terraform.example.com=${{ secrets.TF_REGISTRY_TOKEN }}
420425 TERRAFORM_SSH_KEY: ${{ secrets.TERRAFORM_SSH_KEY }}
421426
427+ permissions:
428+ contents: read
429+ pull-requests: write
430+
422431jobs:
423432 plan:
424433 runs-on: ubuntu-latest
@@ -451,6 +460,10 @@ name: Terraform Plan
451460
452461on: [issue_comment]
453462
463+ permissions:
464+ contents: read
465+ pull-requests: write
466+
454467jobs:
455468 plan:
456469 if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'terraform plan') }}
You can’t perform that action at this time.
0 commit comments