Skip to content

consolidate deployment by introducing backend configs and a Makefile #74

consolidate deployment by introducing backend configs and a Makefile

consolidate deployment by introducing backend configs and a Makefile #74

Workflow file for this run

name: Deployment
on:
push:
branches:
- development
- main
env:
PIPELINE_SA_KEY: ${{ secrets.GCP_SA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: |
cd src
npm ci
npm run test
deploy:
if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [test]
defaults:
run:
working-directory: ./terraform
steps:
- uses: actions/checkout@v6
- name: Google Cloud Auth
uses: 'google-github-actions/auth@v3'
with:
project_id: 'httparchive'
credentials_json: ${{ env.PIPELINE_SA_KEY }}
- uses: hashicorp/setup-terraform@v3
- name: Set environment variable depending on the branch name
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "ENV=prod" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/development" ]]; then
echo "ENV=dev" >> $GITHUB_ENV
fi
- name: Terraform Validate & Plan
id: plan
run: make tf_plan ENV=${{ env.ENV }}
continue-on-error: true
- name: Terraform Plan status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
id: apply
run: make tf_apply ENV=${{ env.ENV }}