Build & Publish refs/master (7c3858095393ff956c89c1779e3ec9b1de04fba3) #39
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 Package | |
run-name: "Build & Publish refs/${{ github.ref_name }} (${{ github.sha }})" | |
on: | |
push: | |
branches: | |
- "staging" | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
package-amd64: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: | | |
network=host | |
buildkitd-flags: "--allow-insecure-entitlement network.host" | |
platforms: | | |
linux/amd64 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install Cargo Binstall | |
uses: cargo-bins/cargo-binstall@main | |
- name: Install SQLx CLI binary | |
run: cargo binstall --no-confirm --force sqlx-cli | |
- name: Set up database | |
run: ./setupdb.sh | |
env: | |
SKIP_TOOL_CHECKS: "1" | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: | | |
linux/amd64 | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:latest-amd64" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
network: host | |
package-aarch64: | |
runs-on: self-hosted | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: 'Cleanup build folder (self-hosted runner)' | |
run: | | |
ls -la ./ | |
rm -rf ./* || true | |
rm -rf ./.??* || true | |
ls -la ./ | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: | | |
network=host | |
buildkitd-flags: "--allow-insecure-entitlement network.host" | |
platforms: | | |
linux/arm64 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install Cargo Binstall | |
uses: cargo-bins/cargo-binstall@main | |
- name: Install SQLx CLI binary | |
run: cargo binstall --no-confirm --force sqlx-cli | |
- name: Set up database | |
run: ./setupdb.sh | |
env: | |
SKIP_TOOL_CHECKS: "1" | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: | | |
linux/arm64 | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:latest-arm64" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
network: host | |
- name: Cleanup dev database (self-hosted runner) | |
if: always() | |
run: docker stop zling-db || true && docker rm zling-db || true | |
run-and-archive-openapi: | |
runs-on: ubuntu-latest | |
needs: package-amd64 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Set up database | |
run: ./setupdb.sh | |
env: | |
# so we don't have to install sqlx-cli, the binary should take care of | |
# all of that automatically | |
SKIP_MIGRATIONS: "1" | |
SKIP_TOOL_CHECKS: "1" | |
- name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: docker pull ${{ env.IMAGE_NAME }}:latest | |
- name: Run server | |
run: docker run -d --rm --network host -e DB_HOST=127.0.0.1 ${{ env.IMAGE_NAME }}:latest && sleep 3 | |
- name: Download openapi.json | |
run: curl -o openapi.json http://localhost:8080/openapi.json | |
- name: Upload openapi.json | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openapi.json | |
path: openapi.json | |
create-joined-image: | |
runs-on: ubuntu-latest | |
needs: | |
- package-amd64 | |
- package-aarch64 | |
permissions: | |
packages: write | |
steps: | |
- name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create new joined manifest | |
run: docker manifest create ${{ env.IMAGE_NAME }}:latest --amend ${{ env.IMAGE_NAME }}:latest-amd64 ${{ env.IMAGE_NAME }}:latest-arm64 | |
- name: Push to registry | |
run: docker manifest push ${{ env.IMAGE_NAME}}:latest | |