-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (59 loc) · 1.96 KB
/
apply-on-merge.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
name: Apply on merge
on:
pull_request:
types:
- closed
jobs:
terraform-apply:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Terraform fmt
id: fmt
run: |
docker run --platform linux/amd64 \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform fmt
continue-on-error: false
shell: bash
- name: Terraform Init
id: init
run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform hashicorp/terraform init -upgrade
continue-on-error: false
shell: bash
- name: Terraform Validate
id: validate
run: |
docker run --platform linux/amd64 \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform validate -no-color
continue-on-error: false
shell: bash
- name: Terraform Plan
id: plan
run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform plan \
-var="hcloud_token=${{ secrets.HCLOUD_TOKEN }}" \
-no-color -lock=false -out terraform.plan
continue-on-error: true
shell: bash
- name: Terraform Apply
id: apply
run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform apply \
-var="hcloud_token=${{ secrets.HCLOUD_TOKEN }}" \
-no-color -auto-approve -input=false
continue-on-error: false
shell: bash