-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (46 loc) · 1.46 KB
/
deploy.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
55
56
name: deploy
on:
push:
branches:
- main
permissions:
contents: read
env:
WORKING_DIR: "terraform/"
jobs:
deployment-check:
runs-on: ubuntu-latest
outputs: # set outputs for use in downstream jobs
continue: ${{ steps.deployment-check.outputs.continue }}
sha: ${{ steps.deployment-check.outputs.sha }}
steps:
# https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md
- name: deployment check
uses: github/branch-deploy@v10
id: deployment-check
with:
merge_deploy_mode: "true"
environment: production
deploy:
if: ${{ needs.deployment-check.outputs.continue == 'true' && github.event_name == 'push' }}
needs: deployment-check
environment: production
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.deployment-check.outputs.sha }}
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # [email protected]
with:
terraform_version: 1.1.7
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform init
run: terraform init
- name: Terraform apply
env:
TF_VAR_CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
run: terraform apply -auto-approve