-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add workflow to update pg_upgrade binary nix flake version on-…
…demand
- Loading branch information
Showing
2 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: Publish nix pg_upgrade_bin flake version | ||
|
||
on: | ||
push: | ||
branches: | ||
- pcnc/nix-flake-workflow | ||
paths: | ||
- '.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml' | ||
workflow_dispatch: | ||
inputs: | ||
postgresVersion: | ||
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78' | ||
required: false | ||
|
||
permissions: | ||
id-token: write | ||
|
||
jobs: | ||
publish-staging: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Grab release version | ||
id: process_release_version | ||
run: | | ||
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g') | ||
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then | ||
VERSION=${{ inputs.postgresVersion }} | ||
fi | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT" | ||
- name: Create a tarball containing the latest nix flake version | ||
working-directory: /tmp/ | ||
run: | | ||
mkdir -p ${{ steps.process_release_version.outputs.major_version }} | ||
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version | ||
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }} | ||
- name: configure aws credentials - staging | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.DEV_AWS_ROLE }} | ||
aws-region: "us-east-1" | ||
|
||
- name: Upload pg_upgrade scripts to s3 staging | ||
run: | | ||
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 | ||
- name: Slack Notification on Failure | ||
if: ${{ failure() }} | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} | ||
SLACK_USERNAME: 'gha-failures-notifier' | ||
SLACK_COLOR: 'danger' | ||
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed' | ||
SLACK_FOOTER: '' | ||
|
||
publish-prod: | ||
runs-on: ubuntu-latest | ||
if: github.ref_name == 'develop' || contains( github.ref, 'release' ) | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Grab release version | ||
id: process_release_version | ||
run: | | ||
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g') | ||
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then | ||
VERSION=${{ inputs.postgresVersion }} | ||
fi | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT" | ||
- name: Create a tarball containing the latest nix flake version | ||
run: | | ||
mkdir -p /tmp/${{ steps.process_release_version.outputs.major_version }} | ||
echo $GITHUB_SHA > /tmp/${{ steps.process_release_version.outputs.major_version }}/nix_flake_version | ||
tar -czvf pg_upgrade_bin.tar.gz -C /tmp/ /${{ steps.process_release_version.outputs.major_version }} | ||
- name: configure aws credentials - prod | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.PROD_AWS_ROLE }} | ||
aws-region: "us-east-1" | ||
|
||
- name: Upload pg_upgrade scripts to s3 prod | ||
run: | | ||
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 | ||
- name: Slack Notification on Failure | ||
if: ${{ failure() }} | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} | ||
SLACK_USERNAME: 'gha-failures-notifier' | ||
SLACK_COLOR: 'danger' | ||
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed' | ||
SLACK_FOOTER: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
postgres-version = "15.6.1.113" | ||
postgres-version = "15.6.1.113-workflow-release-test" |