Build & Publish refs/master (6ef6cbb2cc2b0a4dc1b8693a166e795fa16ede80) #25
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" | |
- 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 sqlx-cli | |
- name: Set up database | |
run: ./setupdb.sh | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:latest" | |
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" | |
- 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 sqlx-cli | |
- name: Set up database | |
run: ./setupdb.sh | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:latest" | |
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 | |
archive-openapi-spec: | |
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 | |
- name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run server | |
run: docker run -d --rm --network host -e BIND_ADDR=127.0.0.1:8080 ${{ env.IMAGE_NAME }}:latest | |
- 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 |