v0.3.1 #13
Workflow file for this run
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 image | |
on: | |
workflow_dispatch: | |
inputs: | |
platforms: | |
description: The platforms built docker image should support | |
type: string | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
PLATFORMS: ${{ inputs.platforms || 'linux/amd64,linux/arm64/v8' }} | |
DH_REGISTRY: index.docker.io | |
DH_NAME: kamontat/dotfiles | |
GH_REGISTRY: ghcr.io | |
GH_NAME: ${{ github.repository }} | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- 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: ${{ secrets.DH_USERNAME }} | |
password: ${{ secrets.DH_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GH_REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DH_NAME }} | |
${{ env.GH_REGISTRY }}/${{ env.GH_NAME }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
- name: Validate docker build configuration | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile | |
call: check | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
- name: Build & Push docker image | |
id: docker-push | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile | |
platforms: ${{ env.PLATFORMS }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
secrets: | | |
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" | |
- name: Attest Docker Hub | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.DH_REGISTRY }}/${{ env.DH_NAME }} | |
subject-digest: ${{ steps.docker-push.outputs.digest }} | |
push-to-registry: true | |
- name: Attest GitHub Container Registry | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.GH_REGISTRY }}/${{ env.GH_NAME }} | |
subject-digest: ${{ steps.docker-push.outputs.digest }} | |
push-to-registry: true |