forked from stackgen-demo/hello-kitty
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 1.87 KB
/
infra-pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: infra-pr
on:
pull_request:
branches:
- main
paths:
- 'infra/terraform/**'
- '.github/workflows/**'
env:
TF_STATE_BUCKET: "stackgen-meetup-terraform-state"
AWS_REGION: "us-west-2"
jobs:
plan:
permissions:
id-token: write
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::222634395437:role/sep-24-meetup-oidc-github
- name: Create backend.tf
run: |
cat <<EOF > ./infra/terraform/backend.tf
terraform {
backend "s3" {}
}
EOF
- name: Terraform Init
run: |
terraform init \
-backend-config="bucket=${{ env.TF_STATE_BUCKET }}" \
-backend-config="key=${{ github.repository }}/terraform.tfstate" \
-backend-config="region=${{ env.AWS_REGION }}"
working-directory: ./infra/terraform
- name: Terraform Plan
id: plan
run: terraform plan -no-color --var region=${{ env.AWS_REGION }}
working-directory: ./infra/terraform
continue-on-error: true
- name: Comment Terraform Plan Output
uses: thollander/[email protected]
with:
message: |
Terraform Plan Output:
```
${{ steps.plan.outputs.stdout }}
```
mode: 'recreate'