Skip to content

feat: attempt to trigger terraform automatically after be #153

feat: attempt to trigger terraform automatically after be

feat: attempt to trigger terraform automatically after be #153

Workflow file for this run

on:
push:
branches:
- 'main'
workflow_dispatch:
workflow_run:
workflows: [Terraform] # Name of GitHub workflow to trigger in target repository
types:
- completed
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'eu-west-2'
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
with:
submodules: true
- name: Install
run: |
npm install
- name: Start LocalStack
run: |
pip install localstack awscli-local[ver1]
docker pull localstack/localstack
localstack start -d
echo "Waiting for LocalStack startup..."
localstack wait -t 30
echo "Startup complete"
- name: Build
run: npm run build
- name: Move Zip files
run: |
mkdir archives
mv .serverless/*.zip archives
- name: Copy Zip files to S3
run: aws s3 cp archives s3://d2e-lambda-s3-bucket --recursive
- name: Copy GraphQL schema to S3
run: aws s3 cp --content-type text/plain schema.graphql s3://d2e-lambda-s3-bucket
trigger-terraform-workflow:
if: github.event.workflow_run.conclusion == 'success' # Run only when workflow run has succeeded, i.e. all jobs have succeeded
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.PAT }} # Fine-grained GitHub PAT that was saved as repository secret
script: |
await github.rest.actions.createworkflowDispatch({
owner: 'CapgeminiInventUK',
repo: 'donate-to-educate-terraform',
workflow_id: 'terraform.yml',
ref: 'main'
})