-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (111 loc) · 3.53 KB
/
Copy pathterraform.yaml
File metadata and controls
111 lines (111 loc) · 3.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Terraform
on:
workflow_call:
inputs:
artifact-name:
type: string
required: false
artifact-path:
type: string
required: false
aws-region:
type: string
required: true
aws-account-id:
type: string
required: true
working-directory:
type: string
required: true
terraform-version:
type: string
required: false
default: "1.1.7"
workspace:
type: string
required: false
default: default
refresh:
type: boolean
required: false
default: false
apply:
type: boolean
required: false
default: false
secrets:
ssh-private-key:
required: false
jobs:
terraform:
name: Terraform
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifact
if: inputs.artifact-name != '' && inputs.artifact-path != ''
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.artifact-path }}
- name: Download all artifacts
if: inputs.artifact-name == '' && inputs.artifact-path != ''
uses: actions/download-artifact@v4
with:
path: ${{ inputs.artifact-path }}
- name: Extract artifacts
if: inputs.artifact-path != ''
run: find ${{ inputs.artifact-path }} -name '*.tar' -execdir tar -xvf '{}' \;
- name: Setup
id: setup
uses: lickdltd/setup-action@v1
with:
aws-region: ${{ inputs.aws-region }}
aws-account-id: ${{ inputs.aws-account-id }}
ssh-private-key: ${{ secrets.ssh-private-key }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ inputs.terraform-version }}
- name: Format
id: fmt
working-directory: ${{ inputs.working-directory }}
run: terraform fmt -check
- name: Initialise
id: init
working-directory: ${{ inputs.working-directory }}
env:
GIT_SSH_COMMAND: "ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=~/.ssh/known_hosts"
run: terraform init -upgrade
- name: Create workspace
if: inputs.workspace != 'default'
working-directory: ${{ inputs.working-directory }}
run: terraform workspace new ${{ inputs.workspace }} -no-color
continue-on-error: true
- name: Select workspace
if: inputs.workspace != 'default'
working-directory: ${{ inputs.working-directory }}
run: terraform workspace select ${{ inputs.workspace }} -no-color
- name: Validate
id: validate
working-directory: ${{ inputs.working-directory }}
run: terraform validate -no-color
- name: Refresh
if: inputs.refresh == true
run: echo "Terraform refresh step deprecated and is no longer executed"
- name: Plan
if: inputs.apply == false
working-directory: ${{ inputs.working-directory }}
env:
TF_VAR_docker_tag: ${{ steps.setup.outputs.git-hash-short }}
run: terraform plan -no-color -compact-warnings -input=false
- name: Apply
if: inputs.apply == true
working-directory: ${{ inputs.working-directory }}
env:
TF_VAR_docker_tag: ${{ steps.setup.outputs.git-hash-short }}
run: terraform apply -compact-warnings -auto-approve -input=false