-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (72 loc) · 2.58 KB
/
tf-release.yaml
File metadata and controls
84 lines (72 loc) · 2.58 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Terraform Release
on:
workflow_call:
inputs:
WORKING_DIRECTORY:
type: string
required: false
default: "."
ENVIRONMENT:
type: string
required: true
USE_CUSTOM_ARTIFACTS:
type: boolean
default: false
required: false
description: "if set to true, the action will download custom artifacts to the working directory (analogous to the 'normal' download step)"
CUSTOM_ARTIFACT_PATH:
type: string
required: false
default: ""
secrets:
GCP_JSON_KEY:
required: false
description: "can be inherited by using the 'inherit' keyword https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsecretsinherit"
env:
TERRAFORM_VERSION: 1.13.4
concurrency:
group: terraform-${{ inputs.ENVIRONMENT }}
cancel-in-progress: false
jobs:
terraform-release:
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v5.0.0
- name: secrets-to-env
uses: oNaiPs/secrets-to-env-action@v1.5
with:
secrets: ${{ toJSON(secrets) }}
include: TF_VAR_*
- name: install terraform
uses: hashicorp/setup-terraform@v3.1.2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: authenticate to google cloud
id: auth
uses: google-github-actions/auth@v3.0.0
with:
credentials_json: "${{ secrets.GCP_JSON_KEY }}"
- name: download a build artifact
uses: actions/download-artifact@v6.0.0
id: download
with:
name: artifacts_${{inputs.ENVIRONMENT}}_${{github.sha}}
path: ${{ inputs.WORKING_DIRECTORY }}
- name: download a custom build artifact
uses: actions/download-artifact@v6.0.0
id: download-custom
if: ${{ inputs.USE_CUSTOM_ARTIFACTS == true }}
with:
name: custom_artifacts_${{inputs.ENVIRONMENT}}_${{github.sha}}
path: ${{ inputs.WORKING_DIRECTORY }}/${{ inputs.CUSTOM_ARTIFACT_PATH }}
- name: terraform init
run: terraform init
- name: terraform select workspace
run: terraform workspace select ${{inputs.ENVIRONMENT}} || terraform workspace new ${{inputs.ENVIRONMENT}} && terraform workspace select ${{inputs.ENVIRONMENT}}
- name: terraform apply
run: terraform apply -auto-approve -no-color plan_${{inputs.ENVIRONMENT}}_${{github.sha}}.bin