0.subscriber-01.6 #131
Workflow file for this run
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
name: publish-sql-schema | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
force: | |
description: force overwrite of migrations | |
default: false | |
required: false | |
type: boolean | |
jobs: | |
push-schema: | |
permissions: | |
id-token: "write" | |
contents: "read" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: "gcp-auth" | |
name: "Authenticate to GCP" | |
uses: "google-github-actions/auth@v1" | |
with: | |
workload_identity_provider: ${{ vars.GCP_ARTIFACT_PUBLISHER_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ vars.GCP_ARTIFACT_PUBLISHER_DEPLOY_SERVICE_ACCOUNT }} | |
- name: Get the version | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF/refs\/tags\//} | |
echo "minor_version=$(echo ${VERSION} | awk -F'.' '{if (NF != 3) {exit 1}; printf "%s.%s", $1, $2}')" >> $GITHUB_OUTPUT | |
- name: Check validity of migrations | |
uses: "./.github/actions/validate-migrations" | |
- name: Check that existing migrations have not changed | |
if: '!inputs.force' | |
run: | | |
TEMP=$(mktemp -d) | |
gcloud alpha storage cp --recursive \ | |
"gs://janus-artifacts-sql-schemas/${{ steps.get_version.outputs.minor_version }}/db" \ | |
"$TEMP" | |
# --diff-filter=a includes all differences except added files. | |
if ! git diff --no-index --diff-filter=a "$TEMP/db" "./db"; then | |
echo "fatal: migrations cannot be modified or removed, only added" | |
exit 1 | |
fi | |
- name: "Upload schema file(s)" | |
if: '!inputs.force' | |
run: |- | |
gcloud alpha storage cp --recursive --no-clobber \ | |
db \ | |
gs://janus-artifacts-sql-schemas/${{ steps.get_version.outputs.minor_version }}/ | |
- name: "Overwrite schema file(s)" | |
if: inputs.force | |
run: |- | |
gcloud alpha storage rm --recursive gs://janus-artifacts-sql-schemas/${{ steps.get_version.outputs.minor_version }}/ | |
gcloud alpha storage cp --recursive \ | |
db \ | |
gs://janus-artifacts-sql-schemas/${{ steps.get_version.outputs.minor_version }}/ |