Files
grimmory/.github/workflows/preview-image.yml
T
dependabot[bot] cd6f37a8d6 chore(deps): bump docker/build-push-action from 6.19.2 to 7.0.0 (#3)
Dependabot couldn't find the original pull request head commit, f110823720b6dd773df014ba288a126d8837fe28.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-20 15:51:42 -05:00

83 lines
2.4 KiB
YAML

name: Preview - Build Image
on:
workflow_dispatch:
inputs:
ref:
description: 'Git ref to preview build'
required: true
type: string
pr_number:
description: 'Optional PR number for a pr-<number>-<sha> tag'
required: false
default: ''
type: string
jobs:
build-and-push:
name: Build and Push Preview Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Generate Preview Tag
env:
PR_NUMBER: ${{ inputs.pr_number }}
run: |
short_sha=$(git rev-parse --short HEAD)
if [ -n "$PR_NUMBER" ]; then
case "$PR_NUMBER" in
(*[!0-9]*)
echo "Invalid PR number: $PR_NUMBER"
exit 1
;;
esac
preview_tag="pr-${PR_NUMBER}-${short_sha}"
else
preview_tag="preview-${short_sha}"
fi
echo "preview_tag=$preview_tag" >> "$GITHUB_ENV"
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
echo "Preview tag: $preview_tag"
- name: Set Up QEMU for Multi-Arch Builds
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push Preview image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/grimmory-tools/grimmory:${{ env.preview_tag }}
build-args: |
APP_VERSION=${{ env.preview_tag }}
APP_REVISION=${{ env.commit_sha }}
cache-from: |
type=gha
type=registry,ref=ghcr.io/grimmory-tools/grimmory:buildcache
cache-to: type=gha,mode=max