Xboard/.github/workflows/docker-publish.yml

89 lines
3.1 KiB
YAML
Raw Normal View History

2023-11-17 01:44:01 -05:00
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ "new" ]
2023-11-17 01:44:01 -05:00
# Publish semver tags as releases.
2024-09-05 22:08:17 -04:00
workflow_dispatch: # Enable manual trigger
2023-11-17 01:44:01 -05:00
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
2024-07-29 01:09:25 -04:00
- uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
2023-11-17 01:44:01 -05:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Install cosign
2024-03-20 07:29:16 -04:00
uses: sigstore/cosign-installer@v3.4.0
2024-03-20 07:41:45 -04:00
with:
cosign-release: 'v2.2.2'
2024-03-20 07:29:16 -04:00
2023-11-17 01:44:01 -05:00
- name: Set up Docker Buildx
2024-03-20 07:29:16 -04:00
uses: docker/setup-buildx-action@v3.2.0
2023-11-17 01:44:01 -05:00
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
2024-03-20 07:29:16 -04:00
uses: docker/login-action@v3.1.0
2023-11-17 01:44:01 -05:00
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
2024-03-20 07:29:16 -04:00
uses: docker/metadata-action@v5.5.1
2023-11-17 01:44:01 -05:00
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2024-09-05 22:08:17 -04:00
2023-11-17 01:44:01 -05:00
- name: Get version
id: get_version
run: echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: build-and-push
2024-03-20 07:29:16 -04:00
uses: docker/build-push-action@v5.3.0
2023-11-17 01:44:01 -05:00
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:new,${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard,${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:${{ steps.get_version.outputs.version }}
2023-11-17 01:44:01 -05:00
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}