Skip to content

Commit 65f1549

Browse files
committed
chore: improve migration workflows
1 parent 1f2520e commit 65f1549

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release Migrations - Prod
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: [self-hosted, linux]
9+
timeout-minutes: 15
10+
permissions:
11+
id-token: write
12+
contents: read
13+
14+
steps:
15+
- name: Guard
16+
run: |
17+
if [ $GITHUB_REF != 'refs/heads/develop' ]; then
18+
echo "This action can only be run on the develop branch"
19+
exit 1
20+
fi
21+
env:
22+
GITHUB_REF: ${{ github.ref }}
23+
24+
- name: Checkout Repo
25+
uses: actions/checkout@v2
26+
27+
- name: Merging migration files
28+
run: cat $(ls -1) > ../migration-output.sql
29+
working-directory: ${{ github.workspace }}/migrations/db/migrations
30+
31+
- name: configure aws credentials - prod
32+
uses: aws-actions/configure-aws-credentials@v1
33+
with:
34+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
35+
aws-region: "ap-southeast-1"
36+
37+
- name: Deploy to S3 prod
38+
shell: bash
39+
run: aws s3 sync migrations/db s3://$AWS_S3_BUCKET/migrations/db --delete
40+
env:
41+
AWS_S3_BUCKET: ${{ secrets.PG_INIT_SCRIPT_S3_BUCKET_PROD }}

.github/workflows/publish-migrations.yml .github/workflows/publish-migrations-staging.yml

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Migrations
1+
name: Release Migrations - Staging
22

33
on:
44
push:
@@ -32,15 +32,3 @@ jobs:
3232
run: aws s3 sync migrations/db s3://$AWS_S3_BUCKET/migrations/db --delete
3333
env:
3434
AWS_S3_BUCKET: ${{ secrets.PG_INIT_SCRIPT_S3_BUCKET_STAGING }}
35-
36-
- name: configure aws credentials - prod
37-
uses: aws-actions/configure-aws-credentials@v1
38-
with:
39-
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
40-
aws-region: "ap-southeast-1"
41-
42-
- name: Deploy to S3 prod
43-
shell: bash
44-
run: aws s3 sync migrations/db s3://$AWS_S3_BUCKET/migrations/db --delete
45-
env:
46-
AWS_S3_BUCKET: ${{ secrets.PG_INIT_SCRIPT_S3_BUCKET_PROD }}

0 commit comments

Comments
 (0)