Skip to content

fix #1

fix #1 #18

Workflow file for this run

---
name: Ship Docker Image
on:
push:
branches:
- main
release:
types:
- published
permissions:
contents: read
packages: write
concurrency:
group: queue
jobs:
information:
name: ℹ️ Gather add-on information
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.information.outputs.architectures }}
build: ${{ steps.information.outputs.build }}
environment: ${{ steps.release.outputs.environment }}
signer: ${{ steps.information.outputs.codenotary_signer }}
slug: ${{ steps.information.outputs.slug }}
target: ${{ steps.information.outputs.target }}
version: ${{ steps.release.outputs.version }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚀 Run add-on information action
id: information
uses: frenck/action-addon-information@v1.4.2
with:
path: server/
- name: ℹ️ Gather version and environment
id: release
run: |
sha="${{ github.sha }}"
environment="edge"
version="${sha:0:7}"
if [[ "${{ github.event_name }}" = "release" ]]; then
version="${{ github.event.release.tag_name }}"
version="${version,,}"
version="${version#v}"
environment="stable"
if [[ "${{ github.event.release.prerelease }}" = "true" ]]; then
environment="beta"
fi
fi
echo "environment=${environment}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
deploy:
name: 👷 Build & Deploy ${{ matrix.architecture }}
needs: information
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🏗 Set up build cache
id: cache
uses: actions/cache@v4.0.2
with:
path: /tmp/.docker-cache
key:
docker-${{ github.ref }}-${{ matrix.architecture }}-${{ github.sha
}}
restore-keys: |
docker-${{ github.ref }}-${{ matrix.architecture }}
- name: 🏗 Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: 🏗 Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: ℹ️ Compose build flags
id: flags
run: |
echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
echo "from=${from}" >> "$GITHUB_OUTPUT"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "platform=linux/amd64" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "platform=linux/386" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "platform=linux/arm/v6" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "platform=linux/arm/v7" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "platform=linux/arm64/v8" >> "$GITHUB_OUTPUT"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
fi
- name: 🏗 Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🚀 Build
uses: docker/build-push-action@v5.3.0
with:
load: true
# yamllint disable rule:line-length
tags: |
ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}
ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}
# yamllint enable rule:line-length
context: "."
file: ${{ needs.information.outputs.target }}/Dockerfile.addon
cache-from: |
type=local,src=/tmp/.docker-cache
ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
cache-to: type=local,mode=max,dest=/tmp/.docker-cache
platforms: ${{ steps.flags.outputs.platform }}
build-args: |
BUILD_ARCH=${{ matrix.architecture }}
BUILD_DATE=${{ steps.flags.outputs.date }}
BUILD_FROM=${{ steps.flags.outputs.from }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ github.repository }}
BUILD_VERSION=${{ needs.information.outputs.version }}
- name: 🚀 Push
# yamllint disable rule:line-length
run: |
docker push \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}"
docker push \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}"
manifest:
name: 👷 Build & Deploy Multi Arch Manifest
needs:
- information
- deploy
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🏗 Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: 🚀 Create manifest
shell: bash
# yamllint disable rule:line-length
run: |
declare -a images
for architecture in $( \
echo '${{ needs.information.outputs.architectures }}' \
| jq --raw-output '.[]'
); do
images+=("ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}/${architecture}:${{ needs.information.outputs.version }}")
done
docker manifest create \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}:${{ needs.information.outputs.environment }}" \
"${images[@]}"
docker manifest create \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}:${{ needs.information.outputs.version }}" \
"${images[@]}"
- name: 🏗 Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🚀 Push
# yamllint disable rule:line-length
run: |
docker manifest push \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}:${{ needs.information.outputs.environment }}"
docker manifest push \
"ghcr.io/${{ github.repository }}/${{ needs.information.outputs.slug }}:${{ needs.information.outputs.version }}"