chore: revert this to working version #33
Workflow file for this run
This file contains hidden or 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: Release all major versions on Dockerhub | |
on: | |
push: | |
branches: | |
- develop | |
- release/* | |
- sam/docker-oriole17 | |
paths: | |
- '**' | |
workflow_dispatch: | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix_config: ${{ steps.set-matrix.outputs.matrix_config }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Generate build matrix | |
id: set-matrix | |
run: | | |
# Get all postgres versions from vars.yml | |
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml) | |
# Create matrix config | |
MATRIX_CONFIG="{" | |
MATRIX_CONFIG+="\"include\":[" | |
FIRST=true | |
while IFS= read -r version; do | |
# Remove quotes from version | |
version=$(echo "$version" | tr -d '"') | |
# Simply look for Dockerfile-{version} | |
dockerfile="Dockerfile-${version}" | |
# Check if Dockerfile exists | |
if [ -f "$dockerfile" ]; then | |
if [ "$FIRST" = true ]; then | |
FIRST=false | |
else | |
MATRIX_CONFIG+="," | |
fi | |
MATRIX_CONFIG+="{\"version\":\"$version\",\"dockerfile\":\"$dockerfile\"}" | |
fi | |
done <<< "$VERSIONS" | |
MATRIX_CONFIG+="]}" | |
# Output the matrix configuration | |
echo "matrix_config=$MATRIX_CONFIG" >> $GITHUB_OUTPUT | |
build: | |
needs: prepare | |
strategy: | |
matrix: ${{ fromJson(needs.prepare.outputs.matrix_config) }} | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.combine-outputs.outputs.versions }} | |
image_tags: ${{ steps.combine-outputs.outputs.image_tags }} | |
build_args: ${{ steps.args.outputs.result }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Set PostgreSQL version environment variable | |
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV | |
- name: Generate common-nix.vars.pkr.hcl | |
run: | | |
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres${{ matrix.version }}"]' ansible/vars.yml) | |
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes | |
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl | |
echo "" >> common-nix.vars.pkr.hcl | |
- id: settings | |
run: sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT | |
- id: args | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml' | |
# Create workflow artifact with this matrix run's version info | |
- name: Save version info | |
run: | | |
mkdir -p ./versions | |
echo "${{ matrix.version }}" > ./versions/version.txt | |
echo "supabase/postgres:${{ steps.settings.outputs.postgres-version }}" > ./versions/tag.txt | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: version-info-${{ matrix.version }} | |
path: ./versions/ | |
- if: matrix.version == fromJson(needs.prepare.outputs.matrix_config).include[0].version | |
id: combine-outputs | |
run: | | |
# Wait for other matrix jobs to complete by sleeping briefly | |
sleep 15 | |
versions_array="[" | |
tags_array="[" | |
first=true | |
# Extract versions directly from matrix config using grep/sed | |
matrix_json='${{ needs.prepare.outputs.matrix_config }}' | |
versions=$(echo "$matrix_json" | grep -o '"version":"[^"]*"' | sed 's/"version":"\(.*\)"/\1/') | |
# For each version | |
while read -r version; do | |
if [ "$first" = true ]; then | |
first=false | |
else | |
versions_array+="," | |
tags_array+="," | |
fi | |
# Get version differently based on version type | |
if [[ "$version" == *"orioledb-"* ]]; then | |
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release.postgresorioledb-17' ansible/vars.yml) | |
else | |
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'$version'"]' ansible/vars.yml) | |
fi | |
PG_VERSION=$(echo $PG_VERSION | tr -d '"') | |
versions_array+="\"${version}\"" | |
tags_array+="\"supabase/postgres:${PG_VERSION}\"" | |
done <<< "$versions" | |
versions_array+="]" | |
tags_array+="]" | |
echo "versions=$versions_array" >> $GITHUB_OUTPUT | |
echo "image_tags=$tags_array" >> $GITHUB_OUTPUT | |
build_release_image: | |
needs: build | |
strategy: | |
matrix: | |
version: ${{ fromJson(needs.build.outputs.versions) }} | |
image_tag: ${{ fromJson(needs.build.outputs.image_tags) }} | |
arch: [amd64, arm64] | |
runs-on: ${{ matrix.arch == 'amd64' && fromJson('["self-hosted", "X64"]') || 'arm-runner' }} | |
timeout-minutes: 180 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: docker context create builders | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
endpoint: builders | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- id: build | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
build-args: | | |
${{ needs.build.outputs.build_args }} | |
target: production | |
tags: ${{ matrix.image_tag }}_${{ matrix.arch }} | |
platforms: linux/${{ matrix.arch }} | |
cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} | |
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} | |
file: Dockerfile-${{ matrix.version }} | |
- name: Slack Notification | |
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: "Building Postgres ${{ matrix.arch }} image failed for version ${{ matrix.version }}" | |
SLACK_FOOTER: "" | |
merge_manifest: | |
needs: [build, build_release_image] | |
strategy: | |
matrix: | |
image_tag: ${{ fromJson(needs.build.outputs.image_tags) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Merge multi-arch manifests | |
run: | | |
docker buildx imagetools create -t ${{ matrix.image_tag }} \ | |
${{ matrix.image_tag }}_amd64 \ | |
${{ matrix.image_tag }}_arm64 | |
- name: Slack Notification | |
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: "Building Postgres image failed for version ${{ matrix.image_tag }}" | |
SLACK_FOOTER: "" | |
get_publish_version: | |
needs: [build, merge_manifest] | |
strategy: | |
matrix: | |
image_tag: ${{ fromJson(needs.build.outputs.image_tags) }} | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- id: get_version | |
run: | | |
# Get the full version from vars.yml for orioledb | |
if [[ "${{ matrix.image_tag }}" == *"orioledb"* ]]; then | |
VERSION=$(nix run nixpkgs#yq -- '.postgres_release.postgresorioledb-17' ansible/vars.yml) | |
VERSION=$(echo $VERSION | tr -d '"') # Remove quotes | |
else | |
# For regular postgres, get version from the image tag | |
VERSION=$(echo "${{ matrix.image_tag }}" | sed 's|supabase/postgres:||') | |
fi | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
publish: | |
needs: get_publish_version | |
uses: ./.github/workflows/mirror.yml | |
with: | |
version: ${{ needs.get_publish_version.outputs.version }} | |
secrets: inherit |