-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (54 loc) · 1.93 KB
/
close_pr.yml
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
name: Close Pull Request
# only trigger on pull request closed events
on:
pull_request:
types: [closed]
jobs:
close_job:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
# All TF variables are define din Terraform Cloud
AWS_REGION: "eu-central-1"
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # ratchet:aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::053932140667:role/mongulu-github
role-session-name: mtchoun-mouh-deployment
aws-region: eu-central-1
- name: Checkout
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # ratchet:actions/checkout@v2
- name: Install terraform
uses: hashicorp/setup-terraform@d22444889af304a44b997011fbabb81ff705a7b4 # ratchet:hashicorp/[email protected]
- name: Checkout
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # ratchet:actions/checkout@v2
- name: Install terraform
uses: hashicorp/setup-terraform@d22444889af304a44b997011fbabb81ff705a7b4 # ratchet:hashicorp/[email protected]
- name: Terraform fmt
id: fmt
run: |
cd infra
terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: |
cd infra
export TF_WORKSPACE=$GITHUB_HEAD_REF
terraform init -backend-config="token=$TFE_TOKEN"
- name: setup workspace
id: workspace
run: |
cd infra
terraform workspace select $GITHUB_HEAD_REF
- name: Terraform Destroy
id: destroy
run: |
cd infra
terraform destroy -auto-approve
terraform workspace select master
terraform workspace delete $GITHUB_HEAD_REF