Skip to content

ci: rewritten the image building action #3062

ci: rewritten the image building action

ci: rewritten the image building action #3062

Workflow file for this run

---
name: CI
on: [ push, pull_request ]
permissions:
contents: write
packages: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
experimental: [false]
rust:
- stable
- beta
include:
- rust: nightly
experimental: true
steps:
- name: install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }}
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose ${{ matrix.features }}
doc:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: doc
args: --verbose
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install cargo-tarpaulin
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-tarpaulin
- name: Run cargo tarpaulin
uses: actions-rs/cargo@v1
env:
TOKEN: ${{ secrets.COVERALLS_TOKEN }}
with:
command: tarpaulin
args: --coveralls $TOKEN
ghcr:
name: Docker build and push to GitHub Container Registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v3
- id: buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- id: config
run: |
var="${{ github.ref_name }}"
if [[ "$var" == "main" || "$var" == v* ]]; then
# TODO: this won't build on arm64, need to fix kawa lib first
# echo arch=linux/amd64,linux/arm64 >> ${GITHUB_OUTPUT}
echo arch=linux/amd64 >> ${GITHUB_OUTPUT}
echo tag=$var >> ${GITHUB_OUTPUT}
else
echo arch=linux/amd64 >> ${GITHUB_OUTPUT}
echo tag=$var >> ${GITHUB_OUTPUT}
fi
- uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: ${{ steps.config.outputs.arch }}
push: ${{ startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') }}
load: ${{ !(startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')) }}
tags: |
ghcr.io/sozu-proxy/sozu:${{ steps.config.outputs.tag }}
- name: Scan image using Grype
id: grype
uses: anchore/scan-action@v5
with:
image: ghcr.io/sozu-proxy/sozu:${{ steps.config.outputs.tag }}
output-format: table
...