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

83 lines
2.2 KiB
YAML
Raw Normal View History

2025-01-06 23:54:07 -05:00
name: Docker Build and Publish
2023-11-17 01:44:01 -05:00
on:
push:
2025-01-06 23:54:07 -05:00
branches: ["new"]
workflow_dispatch:
2023-11-17 01:44:01 -05:00
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
2025-01-06 23:54:07 -05:00
- name: Checkout code
uses: actions/checkout@v4
2025-01-06 23:54:07 -05:00
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
2023-11-17 01:44:01 -05:00
2025-01-06 23:54:07 -05:00
- name: Setup build environment
2023-11-17 01:44:01 -05:00
uses: docker/setup-qemu-action@v3
2025-01-06 23:54:07 -05:00
- name: Setup 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
2025-01-06 23:54:07 -05:00
- name: Login to 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 }}
2025-01-06 23:54:07 -05:00
- name: Extract metadata
2023-11-17 01:44:01 -05:00
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
2025-01-06 23:54:07 -05:00
- name: Build and push
2023-11-17 01:44:01 -05:00
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
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2025-01-06 23:54:07 -05:00
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:new
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:${{ steps.get_version.outputs.version }}
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
2025-01-07 00:29:09 -05:00
- name: Install cosign
uses: sigstore/cosign-installer@v3.4.0
with:
cosign-release: 'v2.2.2'
2025-01-06 23:54:07 -05:00
- name: Sign image
2023-11-17 01:44:01 -05:00
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}