Skip to content

Commit 04a89c3

Browse files
committed
Add permissions in examples
GitHub as decided to break all existing examples by changing the default premissions
1 parent 2f4e5ba commit 04a89c3

File tree

7 files changed

+43
-5
lines changed

7 files changed

+43
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ name: Create terraform plan
5151

5252
on: [pull_request]
5353

54+
permissions:
55+
contents: read
56+
pull-requests: write
57+
5458
jobs:
5559
plan:
5660
runs-on: ubuntu-latest
@@ -77,6 +81,10 @@ on:
7781
branches:
7882
- main
7983

84+
permissions:
85+
contents: read
86+
pull-requests: write
87+
8088
jobs:
8189
apply:
8290
runs-on: ubuntu-latest

example_workflows/apply_plan.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
812
jobs:
913
plan:
1014
runs-on: ubuntu-latest

example_workflows/create_plan.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Create terraform plan
33
on:
44
- pull_request
55

6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
610
jobs:
711
plan:
812
runs-on: ubuntu-latest

example_workflows/validate.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Validate changes
22

33
on:
44
push:
5-
branches:
6-
- '!main'
5+
branches-ignore:
6+
- 'main'
77

88
jobs:
99
fmt-check:

image/Dockerfile-base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

3333
RUN mkdir -p $TF_PLUGIN_CACHE_DIR

terraform-apply/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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

@@ -401,6 +402,10 @@ on:
401402
branches:
402403
- main
403404
405+
permissions:
406+
contents: read
407+
pull-requests: write
408+
404409
jobs:
405410
apply:
406411
runs-on: ubuntu-latest
@@ -516,6 +521,10 @@ on:
516521
branches:
517522
- main
518523
524+
permissions:
525+
contents: read
526+
pull-requests: write
527+
519528
jobs:
520529
plan:
521530
runs-on: ubuntu-latest

terraform-plan/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff 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
386387
on: [pull_request]
387388
389+
permissions:
390+
contents: read
391+
pull-requests: write
392+
388393
jobs:
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+
422431
jobs:
423432
plan:
424433
runs-on: ubuntu-latest
@@ -451,6 +460,10 @@ name: Terraform Plan
451460
452461
on: [issue_comment]
453462
463+
permissions:
464+
contents: read
465+
pull-requests: write
466+
454467
jobs:
455468
plan:
456469
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'terraform plan') }}

0 commit comments

Comments
 (0)