Build #20
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: Build | |
on: | |
workflow_run: | |
workflows: [Validate] | |
types: [completed] | |
branches: ["main"] | |
push: | |
tags: ["v*.*.*"] | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build-docker-images: | |
name: Build Docker images | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} || ${{ github.ref_type == 'tag' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Collect Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ vars.DOCKERHUB_USERNAME }}/sandhole | |
ghcr.io/${{ github.repository }} | |
${{ vars.REGISTRY_HOSTNAME }}/${{ vars.REGISTRY_USERNAME }}/sandhole | |
tags: | | |
type=ref,event=branch | |
type=sha,prefix=,suffix=,enable={{is_default_branch}} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PUSH_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to custom registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.REGISTRY_HOSTNAME }} | |
username: ${{ vars.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PUSH_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile.ci | |
push: true | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Export binaries | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile.ci | |
target: binary | |
outputs: type=local,dest=out | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sandhole-binaries | |
path: out/ | |
create-release-draft: | |
name: Create release draft | |
if: github.ref_type == 'tag' | |
needs: build-docker-images | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: sandhole-binaries | |
path: out/ | |
- name: Create release draft with binary assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create ${{ github.ref_name }} ./out/sandhole-* --draft --verify-tag |