Skip to content

Build & Publish refs/master (3d897d52815128d872b9874fdd7f74e2893cc5e6) #36

Build & Publish refs/master (3d897d52815128d872b9874fdd7f74e2893cc5e6)

Build & Publish refs/master (3d897d52815128d872b9874fdd7f74e2893cc5e6) #36

Workflow file for this run

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"
- 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"
cache-from: type=gha
cache-to: type=gha,mode=max
network: host
provenance: false
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"
- 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"
cache-from: type=gha
cache-to: type=gha,mode=max
network: host
provenance: false
- 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