Files
xread/.github/workflows/image.yml
T

69 lines
1.9 KiB
YAML

name: Container Image
on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
permissions:
contents: read
packages: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: image-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
docker:
name: Build container image
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Prepare licensed assets
run: node ./scripts/prepare-licensed-assets.cjs
- name: Derive image name
id: vars
run: echo "image_name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Extract image metadata
id: meta
uses: docker/metadata-action@4378dc6be7f72231dfe78ac7e0364a44f1c9f54b
with:
images: ${{ steps.vars.outputs.image_name }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@a0d57b8e43b6ef1cca20559d68cec2227e63fccd
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and optionally publish image
uses: docker/build-push-action@b66d8774c665b789105b440514f0c97e6f19b06f
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max