Skip to content

Commit

Permalink
feat: add gh workflow (#180)
Browse files Browse the repository at this point in the history
* feat: add gh workflow

* feat: bump version

* fix: update to mirror Postgres format

* fix: bump version

* chore: mirror image

* fix: bump VERSION

* chore: update publish workflow

* chore: remove local changes

* fix: bump version

---------

Co-authored-by: joel@joellee.org <joel@joellee.org>
Co-authored-by: Qiao Han <qiao@supabase.io>
Co-authored-by: Chase Granberry <chase@logflare.app>
  • Loading branch information
4 people committed Oct 19, 2023
1 parent e3d07da commit 1b2d21e
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Mirror Image

on:
workflow_call:
inputs:
version:
required: true
type: string
workflow_dispatch:
inputs:
version:
description: "Image tag"
required: true
type: string

jobs:
mirror:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2.2.0
with:
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
aws-region: us-east-1
- uses: docker/login-action@v2
with:
registry: public.ecr.aws
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: akhilerm/tag-push-action@v2.1.0
with:
src: docker.io/supabase/supavisor:${{ inputs.version }}
dst: |
public.ecr.aws/supabase/supavisor:${{ inputs.version }}
ghcr.io/supabase/supavisor:${{ inputs.version }}
75 changes: 75 additions & 0 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release on Dockerhub

on:
push:
branches:
- main
paths:
- ".github/workflows/publish_docker.yml"
- "VERSION"

jobs:
settings:
runs-on: ubuntu-latest
outputs:
docker_version: ${{ steps.settings.outputs.result }}
image_tag: supabase/supavisor:${{ steps.settings.outputs.result }}
steps:
- uses: actions/checkout@v3
- id: settings
# Remove spaces to get the raw version string
run: echo "result=$(sed -r 's/\s+//g' VERSION)" >> $GITHUB_OUTPUT

build_image:
needs: settings
strategy:
matrix:
include:
- runner: [self-hosted, X64]
arch: amd64
- runner: arm-runner
arch: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
outputs:
image_digest: ${{ steps.build.outputs.digest }}
steps:
- 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
tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ matrix.arch }}

merge_manifest:
needs: [settings, build_image]
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 ${{ needs.settings.outputs.image_tag }} \
${{ needs.settings.outputs.image_tag }}_amd64 \
${{ needs.settings.outputs.image_tag }}_arm64
publish:
needs: [settings, merge_manifest]
# Call workflow explicitly because events from actions cannot trigger more actions
uses: ./.github/workflows/mirror.yml
with:
version: ${{ needs.settings.outputs.docker_version }}
secrets: inherit
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.18
0.9.19

0 comments on commit 1b2d21e

Please sign in to comment.