rewrite yaml file as well #31
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: Docker build | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
jobs: | |
build-images: | |
name: Build Docker Images | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- tag: amd64 | |
features: "" | |
arch: amd64 | |
rust-target: x86_64-unknown-linux-musl | |
musl-target: x86_64-linux-musl | |
- tag: metrics-amd64 | |
features: expose-metrics | |
arch: amd64 | |
rust-target: x86_64-unknown-linux-musl | |
musl-target: x86_64-linux-musl | |
- tag: armv8 | |
features: "" | |
arch: arm64/v8 | |
rust-target: aarch64-unknown-linux-musl | |
musl-target: aarch64-linux-musl | |
- tag: metrics-armv8 | |
features: expose-metrics | |
arch: arm64/v8 | |
rust-target: aarch64-unknown-linux-musl | |
musl-target: aarch64-linux-musl | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Convert GITHUB_REPOSITORY into lowercase | |
run: | | |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- name: Build and push ${{ matrix.tag }} | |
uses: docker/build-push-action@v5 | |
with: | |
push: github.ref == 'refs/heads/trunk' && github.event_name != 'pull_request' | |
tags: http-proxy:${{ matrix.tag }} | |
build-args: | | |
FEATURES=${{ matrix.features }} | |
RUST_TARGET=${{ matrix.rust-target }} | |
MUSL_TARGET=${{ matrix.musl-target }} | |
create-manifest: | |
name: Create Docker manifests | |
runs-on: ubuntu-latest | |
needs: build-images | |
if: github.ref == 'refs/heads/trunk' && github.event_name != 'pull_request' | |
steps: | |
- name: Login to ghcr | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | podman login -u ${{ github.repository_owner }} --password-stdin ghcr.io | |
- name: Convert GITHUB_REPOSITORY into lowercase | |
run: | | |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- name: Create manifest and push it | |
run: | | |
podman manifest create http-proxy-latest docker://ghcr.io/${REPO}:amd64 docker://ghcr.io/${REPO}:armv8 | |
podman manifest create http-proxy-metrics docker://ghcr.io/${REPO}:metrics-amd64 docker://ghcr.io/${REPO}:metrics-armv8 | |
podman manifest push --format v2s2 http-proxy-latest docker://ghcr.io/${REPO}:latest | |
podman manifest push --format v2s2 http-proxy-metrics docker://ghcr.io/${REPO}:metrics |