Update README.md: tags and usage #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
paths: | |
- 'latest/**' | |
- 'official/**' | |
- versions.json | |
workflow_dispatch: | |
env: | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Set matrix | |
id: set-matrix | |
run: | | |
JSON=$(cat ./versions.json) | |
echo "matrix=$(jq -cM . <<< ${JSON})" >> $GITHUB_OUTPUT | |
image: | |
needs: prepare | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
image: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Send Slack notification | |
uses: codedsolar/slack-action@v1 | |
if: ${{ github.event_name != 'pull_request' }} | |
id: slack | |
with: | |
fields: | | |
{STATUS} | |
{REF} | |
ImageMagick version: ${{ matrix.image.imagemagick }} | |
ktools version: ${{ matrix.image.version }} | |
status: in-progress | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Prepare Docker meta for a Debian image | |
uses: docker/metadata-action@v5 | |
id: debian-meta | |
with: | |
flavor: | | |
prefix=${{ matrix.image.official && 'official-' || '' }},onlatest=${{ matrix.image.official || 'false' }} | |
images: | | |
${{ github.repository_owner }}/ktools | |
ghcr.io/${{ github.repository_owner }}/ktools | |
labels: | | |
[email protected] | |
tags: | | |
type=raw,value=${{ matrix.image.version }} | |
type=raw,value=${{ matrix.image.version }}-debian | |
type=raw,value=${{ matrix.image.version }}-imagemagick-${{ matrix.image.imagemagick }}-debian | |
${{ matrix.image.latest && 'type=raw,value=debian' || '' }} | |
- name: Build a Debian image | |
uses: docker/build-push-action@v5 | |
id: debian | |
with: | |
build-args: | | |
DS_KTOOLS_VERSION=${{ matrix.image.version }} | |
IMAGEMAGICK_VERSION=${{ matrix.image.imagemagick }} | |
cache-from: type=registry,ref=${{ github.repository_owner }}/ktools:${{ matrix.image.official && 'official-' || '' }}${{ matrix.image.version }}-imagemagick-${{ matrix.image.imagemagick }}-debian | |
cache-to: type=inline | |
context: . | |
file: ${{ matrix.image.root }}/debian/Dockerfile | |
labels: ${{ steps.debian-meta.outputs.labels }} | |
platforms: linux/amd64,linux/386 | |
pull: true | |
push: ${{ !env.ACT && github.ref == 'refs/heads/main' }} | |
tags: ${{ steps.debian-meta.outputs.tags }} | |
- name: Prepare Docker meta for an Alpine image | |
uses: docker/metadata-action@v5 | |
id: alpine-meta | |
with: | |
images: | | |
${{ github.repository_owner }}/ktools | |
ghcr.io/${{ github.repository_owner }}/ktools | |
flavor: | | |
latest=${{ matrix.image.latest || 'false' }} | |
prefix=${{ matrix.image.official && 'official-' || '' }},onlatest=${{ matrix.image.official || 'false' }} | |
labels: | | |
[email protected] | |
tags: | | |
type=raw,value=${{ matrix.image.version }} | |
type=raw,value=${{ matrix.image.version }}-alpine | |
type=raw,value=${{ matrix.image.version }}-imagemagick-${{ matrix.image.imagemagick }}-alpine | |
${{ matrix.image.latest && 'type=raw,value=alpine' || '' }} | |
${{ (matrix.image.latest && matrix.image.official) && 'type=raw,prefix=,suffix=,value=official' || '' }} | |
- name: Build an Alpine image | |
uses: docker/build-push-action@v5 | |
id: alpine | |
with: | |
build-args: | | |
DS_KTOOLS_VERSION=${{ matrix.image.version }} | |
IMAGEMAGICK_VERSION=${{ matrix.image.imagemagick }} | |
cache-from: type=registry,ref=${{ github.repository_owner }}/ktools:${{ matrix.image.official && 'official-' || '' }}${{ matrix.image.version }}-imagemagick-${{ matrix.image.imagemagick }}-alpine | |
cache-to: type=inline | |
context: . | |
file: ${{ matrix.image.root }}/alpine/Dockerfile | |
labels: ${{ steps.alpine-meta.outputs.labels }} | |
platforms: linux/amd64,linux/386 | |
pull: true | |
push: ${{ !env.ACT && github.ref == 'refs/heads/main' }} | |
tags: ${{ steps.alpine-meta.outputs.tags }} | |
- name: Update Slack notification | |
uses: codedsolar/slack-action@v1 | |
if: ${{ github.event_name != 'pull_request' && always() }} | |
with: | |
fields: | | |
{STATUS} | |
{REF} | |
ImageMagick version: ${{ matrix.image.imagemagick }} | |
ktools version: ${{ matrix.image.version }} | |
status: ${{ job.status }} | |
timestamp: ${{ steps.slack.outputs.slack-timestamp }} |