Skip to content

Commit caca7a6

Browse files
committed
chore: add workflow to update pg_upgrade binary nix flake version on-demand
1 parent 6acd4c3 commit caca7a6

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
run: |
38+
mkdir -p /tmp/${{ steps.process_release_version.outputs.major_version }}
39+
echo $GITHUB_SHA > /tmp/${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
40+
tar -czvf pg_upgrade_bin.tar.gz -C /tmp/ /${{ steps.process_release_version.outputs.major_version }}
41+
42+
- name: configure aws credentials - staging
43+
uses: aws-actions/configure-aws-credentials@v1
44+
with:
45+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
46+
aws-region: "us-east-1"
47+
48+
- name: Upload pg_upgrade scripts to s3 staging
49+
run: |
50+
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
51+
52+
- name: Slack Notification on Failure
53+
if: ${{ failure() }}
54+
uses: rtCamp/action-slack-notify@v2
55+
env:
56+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
57+
SLACK_USERNAME: 'gha-failures-notifier'
58+
SLACK_COLOR: 'danger'
59+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
60+
SLACK_FOOTER: ''
61+
62+
publish-prod:
63+
runs-on: ubuntu-latest
64+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
65+
66+
steps:
67+
- name: Checkout Repo
68+
uses: actions/checkout@v3
69+
70+
- name: Grab release version
71+
id: process_release_version
72+
run: |
73+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
74+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
75+
VERSION=${{ inputs.postgresVersion }}
76+
fi
77+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
78+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
79+
80+
- name: Create a tarball containing the latest nix flake version
81+
run: |
82+
mkdir -p /tmp/${{ steps.process_release_version.outputs.major_version }}
83+
echo $GITHUB_SHA > /tmp/${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
84+
tar -czvf pg_upgrade_bin.tar.gz -C /tmp/ /${{ steps.process_release_version.outputs.major_version }}
85+
86+
- name: configure aws credentials - prod
87+
uses: aws-actions/configure-aws-credentials@v1
88+
with:
89+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
90+
aws-region: "us-east-1"
91+
92+
- name: Upload pg_upgrade scripts to s3 prod
93+
run: |
94+
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
95+
96+
- name: Slack Notification on Failure
97+
if: ${{ failure() }}
98+
uses: rtCamp/action-slack-notify@v2
99+
env:
100+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
101+
SLACK_USERNAME: 'gha-failures-notifier'
102+
SLACK_COLOR: 'danger'
103+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
104+
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)