Skip to content

Commit 90a93ab

Browse files
pcncdarora
authored andcommitted
chore: add workflow to update pg_upgrade binary nix flake version on-demand
1 parent 6acd4c3 commit 90a93ab

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Publish nix pg_upgrade_bin flake version
2+
3+
on:
4+
push:
5+
branches:
6+
- pcnc/nix-flake-workflow
7+
paths:
8+
- '.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml'
9+
workflow_dispatch:
10+
inputs:
11+
postgresVersion:
12+
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78'
13+
required: false
14+
15+
permissions:
16+
id-token: write
17+
18+
jobs:
19+
publish-staging:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout Repo
24+
uses: actions/checkout@v3
25+
26+
- name: Grab release version
27+
id: process_release_version
28+
run: |
29+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
30+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
31+
VERSION=${{ inputs.postgresVersion }}
32+
fi
33+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
34+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
35+
36+
- name: Create a tarball containing the latest nix flake version
37+
working-directory: /tmp/
38+
run: |
39+
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
40+
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
41+
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
42+
43+
- name: configure aws credentials - staging
44+
uses: aws-actions/configure-aws-credentials@v1
45+
with:
46+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
47+
aws-region: "us-east-1"
48+
49+
- name: Upload pg_upgrade scripts to s3 staging
50+
run: |
51+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
52+
53+
- name: Slack Notification on Failure
54+
if: ${{ failure() }}
55+
uses: rtCamp/action-slack-notify@v2
56+
env:
57+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
58+
SLACK_USERNAME: 'gha-failures-notifier'
59+
SLACK_COLOR: 'danger'
60+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
61+
SLACK_FOOTER: ''
62+
63+
publish-prod:
64+
runs-on: ubuntu-latest
65+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
66+
67+
steps:
68+
- name: Checkout Repo
69+
uses: actions/checkout@v3
70+
71+
- name: Grab release version
72+
id: process_release_version
73+
run: |
74+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
75+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
76+
VERSION=${{ inputs.postgresVersion }}
77+
fi
78+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
79+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
80+
81+
- name: Create a tarball containing the latest nix flake version
82+
run: |
83+
mkdir -p /tmp/${{ steps.process_release_version.outputs.major_version }}
84+
echo $GITHUB_SHA > /tmp/${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
85+
tar -czvf pg_upgrade_bin.tar.gz -C /tmp/ /${{ steps.process_release_version.outputs.major_version }}
86+
87+
- name: configure aws credentials - prod
88+
uses: aws-actions/configure-aws-credentials@v1
89+
with:
90+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
91+
aws-region: "us-east-1"
92+
93+
- name: Upload pg_upgrade scripts to s3 prod
94+
run: |
95+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
96+
97+
- name: Slack Notification on Failure
98+
if: ${{ failure() }}
99+
uses: rtCamp/action-slack-notify@v2
100+
env:
101+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
102+
SLACK_USERNAME: 'gha-failures-notifier'
103+
SLACK_COLOR: 'danger'
104+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
105+
SLACK_FOOTER: ''

common-nix.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.6.1.113"
1+
postgres-version = "15.6.1.113-workflow-release-test"

0 commit comments

Comments
 (0)