-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (57 loc) · 1.89 KB
/
deploy.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
61
62
63
64
65
66
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'
})