Skip to content

Commit

Permalink
Merge pull request #240 from dflook/fix-react
Browse files Browse the repository at this point in the history
Fix react
  • Loading branch information
dflook authored Feb 2, 2023
2 parents 2f77226 + 04a89c3 commit 0741830
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 11 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ name: Create terraform plan

on: [pull_request]

permissions:
contents: read
pull-requests: write

jobs:
plan:
runs-on: ubuntu-latest
Expand All @@ -77,6 +81,10 @@ on:
branches:
- main

permissions:
contents: read
pull-requests: write

jobs:
apply:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions example_workflows/apply_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

permissions:
contents: read
pull-requests: write

jobs:
plan:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions example_workflows/create_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Create terraform plan
on:
- pull_request

permissions:
contents: read
pull-requests: write

jobs:
plan:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions example_workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Validate changes

on:
push:
branches:
- '!main'
branches-ignore:
- 'main'

jobs:
fmt-check:
Expand Down
2 changes: 1 addition & 1 deletion image/Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN apt-get update \
wget \
gpg \
gpg-agent \
dirmngr \
dirmngr \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p $TF_PLUGIN_CACHE_DIR
Expand Down
12 changes: 6 additions & 6 deletions image/actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ function setup() {
exit 1
fi

if [[ ! -v TERRAFORM_ACTIONS_GITHUB_TOKEN ]]; then
if [[ -v GITHUB_TOKEN ]]; then
export TERRAFORM_ACTIONS_GITHUB_TOKEN="$GITHUB_TOKEN"
fi
fi

if ! github_comment_react +1 2>"$STEP_TMP_DIR/github_comment_react.stderr"; then
debug_file "$STEP_TMP_DIR/github_comment_react.stderr"
fi
Expand All @@ -102,12 +108,6 @@ function setup() {

detect-tfmask

if [[ ! -v TERRAFORM_ACTIONS_GITHUB_TOKEN ]]; then
if [[ -v GITHUB_TOKEN ]]; then
export TERRAFORM_ACTIONS_GITHUB_TOKEN="$GITHUB_TOKEN"
fi
fi

execute_run_commands
}

Expand Down
11 changes: 10 additions & 1 deletion terraform-apply/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ These input values must be the same as any `terraform-plan` for the same configu
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

The token provided by GitHub Actions will work with the default permissions.
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.

The minimum permissions are `pull-requests: write`.
It will also likely need `contents: read` so the job can checkout the repo.

Expand Down Expand Up @@ -401,6 +402,10 @@ on:
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
apply:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -516,6 +521,10 @@ on:
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
plan:
runs-on: ubuntu-latest
Expand Down
15 changes: 14 additions & 1 deletion terraform-plan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ The [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

The token provided by GitHub Actions will work with the default permissions.
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.

The minimum permissions are `pull-requests: write`.
It will also likely need `contents: read` so the job can checkout the repo.

Expand Down Expand Up @@ -385,6 +386,10 @@ name: PR Plan
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
plan:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -419,6 +424,10 @@ env:
TERRAFORM_CLOUD_TOKENS: terraform.example.com=${{ secrets.TF_REGISTRY_TOKEN }}
TERRAFORM_SSH_KEY: ${{ secrets.TERRAFORM_SSH_KEY }}
permissions:
contents: read
pull-requests: write
jobs:
plan:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -451,6 +460,10 @@ name: Terraform Plan
on: [issue_comment]
permissions:
contents: read
pull-requests: write
jobs:
plan:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'terraform plan') }}
Expand Down

0 comments on commit 0741830

Please sign in to comment.