-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (57 loc) · 2.4 KB
/
_update_terraform.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
57
58
59
60
name: Update Terraform
on:
workflow_call:
secrets:
PERSONAL_ACCESS_TOKEN:
required: true
inputs:
image_tag:
description: Tag for the image for docker/ghcr registries
required: true
type: string
deployment_environment:
description: The terraform target environment
required: true
type: string
default: staging
jobs:
update:
runs-on: ubuntu-latest
env:
GIT_SHA: ${{ github.sha }}
GIT_TAG: ${{ inputs.image_tag }}
steps:
- name: Checkout terraform config repo
uses: actions/checkout@v4
with:
# public repo with terraform configuration
repository: 'datacite/mastino'
persist-credentials: false
- name: Setup dokerize and template parameters
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
rm dockerize-linux-amd64-v0.6.0.tar.gz
- name: Conditionally update staging environment
if: ${{ (inputs.deployment_environment == 'staging') }}
run: |
./dockerize -template stage/services/levriero/_levriero.auto.tfvars.tmpl:stage/services/levriero/_levriero.auto.tfvars
git add stage/services/levriero/_levriero.auto.tfvars
git commit -m "Adding levriero git variables for commit ${{ github.sha }}"
- name: Conditionally update production/test environments
if: ${{ (inputs.deployment_environment == 'production') }}
run: |
./dockerize -template prod-eu-west/services/levriero/_levriero.auto.tfvars.tmpl:prod-eu-west/services/levriero/_levriero.auto.tfvars
./dockerize -template test/services/levriero/_levriero.auto.tfvars.tmpl:test/services/levriero/_levriero.auto.tfvars
git add prod-eu-west/services/levriero/_levriero.auto.tfvars
git add test/services/levriero/_levriero.auto.tfvars
git commit -m "Adding levriero git variables for tag ${{ inputs.image_tag }}"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: 'datacite/mastino'
branch: 'refs/heads/master'
tags: false