[BUILD] setup action #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: Publish docker artifacts | |
on: | |
push: | |
branches: ["image-builder"] | |
env: | |
REGISTRY: ghcr.io | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
publish-docker: | |
name: Publish Docker image | |
strategy: | |
matrix: | |
workload: ["controller"] | |
# workload: ["controller", "server", "web-hooks"] | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Prepare repository name | |
id: prepare-repository-name | |
run: | | |
repository=$REGISTRY/${{ github.repository }}/${{ matrix.workload }} | |
echo "repository=${repository,,}" >> $GITHUB_OUTPUT | |
- name: Extract metadata (tags, labels) for Docker | |
id: extract-metadata | |
uses: docker/metadata-action@v5 | |
with: | |
tags: | | |
type=sha,format=short | |
images: ${{ steps.prepare-repository-name.outputs.repository }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
file: build/${{ matrix.workload }}/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
cache-from: | | |
type=gha,scope=${{ matrix.workload }}-sha-${{ github.sha }} | |
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }} | |
type=gha,scope=${{ github.base_ref || 'main' }} | |
type=gha,scope=main | |
cache-to: | | |
type=gha,scope=${{ matrix.workload }}-sha-${{ github.sha }},mode=max | |
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }},mode=max | |
push: true | |
tags: ${{ steps.extract-metadata.outputs.tags }} | |
labels: ${{ steps.extract-metadata.outputs.labels }} |