Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gh workflow #180

Merged
merged 10 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Build Production
on:
push:
branches:
- "main"
jobs:
release:
J0 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-20.04
outputs:
published: ${{ steps.semantic.outputs.new_release_published }}
version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- uses: actions/checkout@v3
- id: semantic
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 18
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACTION }}

docker_x86_release:
J0 marked this conversation as resolved.
Show resolved Hide resolved
needs: release
runs-on: ubuntu-20.04
if: needs.release.outputs.published == 'true'
timeout-minutes: 120
env:
arch: amd64
outputs:
image_digest: ${{ steps.build.outputs.digest }}
steps:
- id: meta
uses: docker/metadata-action@v4
with:
images: |
supabase/supavisor
tags: |
type=raw,value=v${{ needs.release.outputs.version }}_${{ env.arch }}
type=raw,value=latest_${{ env.arch }}

- uses: docker/setup-buildx-action@v2

- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- id: build
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/${{ env.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max

docker_arm_release:
needs: release
runs-on: arm-runner
if: needs.release.outputs.published == 'true'
timeout-minutes: 120
env:
arch: arm64
outputs:
image_digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3

- id: meta
uses: docker/metadata-action@v4
with:
images: |
supabase/supavisor
tags: |
type=raw,value=v${{ needs.release.outputs.version }}_${{ env.arch }}
type=raw,value=latest_${{ env.arch }}

- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: docker/setup-buildx-action@v2
with:
driver: docker
driver-opts: |
image=moby/buildkit:master
network=host

- id: build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/${{ env.arch }}
no-cache: true

merge_manifest:
needs: [release, docker_x86_release, docker_arm_release]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: docker/setup-buildx-action@v2

- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Merge multi-arch manifests for versioned output
run: |
docker buildx imagetools create -t supabase/supavisor:v${{ needs.release.outputs.version }} \
supabase/supavisor@${{ needs.docker_x86_release.outputs.image_digest }} \
supabase/supavisor@${{ needs.docker_arm_release.outputs.image_digest }}

- name: Merge multi-arch manifests for latest output
run: |
docker buildx imagetools create -t supabase/supavisor:latest \
supabase/supavisor@${{ needs.docker_x86_release.outputs.image_digest }} \
supabase/supavisor@${{ needs.docker_arm_release.outputs.image_digest }}

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
J0 marked this conversation as resolved.
Show resolved Hide resolved
aws-region: us-east-1

- name: Login to ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Mirror to ECR
uses: akhilerm/tag-push-action@v2.0.0
with:
src: docker.io/supabase/supavisor:v${{ needs.release.outputs.version }}
dst: |
public.ecr.aws/supabase/supavisor:v${{ needs.release.outputs.version }}
ghcr.io/supabase/supavisor:v${{ needs.release.outputs.version }}

update-branch-name:
needs: [release, docker_x86_release, docker_arm_release, merge_manifest]
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
with:
ref: refs/heads/main

- name: Update branch name
run: |
git branch -m main releases/v${{ needs.release.outputs.version }}
git push origin HEAD:releases/v${{ needs.release.outputs.version }}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.10
0.9.11
Loading