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

93 lines
2.6 KiB
YAML
Raw Permalink Normal View History

2025-01-21 01:57:54 -05:00
name: Docker Build and Publish
2023-11-17 01:44:01 -05:00
on:
push:
2025-01-21 01:57:54 -05:00
branches: ["master"]
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-21 01:57:54 -05:00
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
2023-11-17 01:44:01 -05:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
2024-03-20 07:41:45 -04:00
with:
2025-01-21 01:57:54 -05:00
platforms: 'arm64,amd64'
2024-03-20 07:29:16 -04:00
2023-11-17 01:44:01 -05:00
- name: Set up Docker Buildx
2025-01-21 01:57:54 -05:00
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
driver-opts: |
image=moby/buildkit:latest
2023-11-17 01:44:01 -05:00
2025-01-21 01:57:54 -05:00
- name: Login to registry
uses: docker/login-action@v3
2023-11-17 01:44:01 -05:00
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
2025-01-21 01:57:54 -05:00
- name: Extract metadata
2023-11-17 01:44:01 -05:00
id: meta
2025-01-21 01:57:54 -05:00
uses: docker/metadata-action@v5
2023-11-17 01:44:01 -05:00
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2025-01-21 01:57:54 -05:00
tags: |
type=ref,event=branch
type=sha,format=long
type=raw,value=new
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-21 01:57:54 -05:00
- name: Update version in app.php
run: |
VERSION=$(date '+%Y%m%d')-$(git rev-parse --short HEAD)
sed -i "s/'version' => '.*'/'version' => '$VERSION'/g" config/app.php
echo "Updated version to: $VERSION"
- name: Build and push
2023-11-17 01:44:01 -05:00
id: build-and-push
2025-01-21 01:57:54 -05:00
uses: docker/build-push-action@v5
2023-11-17 01:44:01 -05:00
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
2025-01-21 01:57:54 -05:00
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:master
2025-01-21 09:04:08 -05:00
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:new
2025-01-21 01:57:54 -05:00
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:${{ steps.get_version.outputs.version }}
build-args: |
BUILDKIT_INLINE_CACHE=1
provenance: false
- name: Install cosign
uses: sigstore/cosign-installer@v3.4.0
with:
cosign-release: 'v2.2.2'
- name: Sign image
if: steps.build-and-push.outputs.digest != ''
2023-11-17 01:44:01 -05:00
env:
2025-01-21 01:57:54 -05:00
COSIGN_EXPERIMENTAL: 1
run: |
echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --yes "{}@${{ steps.build-and-push.outputs.digest }}"