60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
name: Build & Push DEV to GHCR
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ dev ]
|
|
push:
|
|
branches: [ dev ]
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
# PRs: single-arch build (faster). Push to dev: multi-arch.
|
|
PLATFORMS: ${{ github.event_name == 'pull_request' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Compute DEV tags
|
|
run: |
|
|
SHA7="${GITHUB_SHA::7}"
|
|
echo "SHA7=$SHA7" >> $GITHUB_ENV
|
|
echo "DEV_TAGS=ghcr.io/${GITHUB_REPOSITORY}:dev,ghcr.io/${GITHUB_REPOSITORY}:dev-${SHA7}" >> $GITHUB_ENV
|
|
echo "Computed DEV_TAGS=${{ env.DEV_TAGS }}"
|
|
|
|
- name: Set up QEMU
|
|
if: ${{ env.PLATFORMS == 'linux/amd64,linux/arm64' }}
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build & (maybe) push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: ${{ env.PLATFORMS }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ env.DEV_TAGS }}
|
|
build-args: |
|
|
VERSION=dev-${{ env.SHA7 }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
provenance: false
|