Add release workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 dockerize 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/datafiles/_tesem.auto.tfvars.tmpl:stage/services/datafiles/_tesem.auto.tfvars | ||
git add stage/services/datafiles/_tesem.auto.tfvars | ||
git commit -m "Adding tesem git variables for commit ${{ github.sha }}" | ||
- name: Conditionally update production/test environments | ||
if: ${{ (inputs.deployment_environment == 'production') }} | ||
run: | | ||
./dockerize -template prod-eu-west/services/datafiles/_tesem.auto.tfvars.tmpl:prod-eu-west/services/datafiles/_tesem.auto.tfvars | ||
# ./dockerize -template test/services/datafiles/_tesem.auto.tfvars.tmpl:test/services/datafiles/_tesem.auto.tfvars | ||
git add prod-eu-west/services/datafiles/_tesem.auto.tfvars | ||
# git add test/services/datafiles/_tesem.auto.tfvars | ||
git commit -m "Adding tesem 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 |