Skip to content

CI

CI #96

Workflow file for this run

name: CI
on:
schedule:
- cron: "0 12 * * *"
push:
branches: ["main", "renovate/*"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
id-token: write
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- owner: DakaraProject
repo: dakara-client-web
branch: master
plateforms: linux/amd64,linux/arm64
- owner: DakaraProject
repo: dakara-server
branch: master
plateforms: linux/amd64,linux/arm64
- owner: odrling
repo: filestash
branch: subs
plateforms: linux/amd64
dockerfile: docker/Dockerfile
- owner: odrling
repo: syncplay
branch: master
plateforms: linux/amd64,linux/arm64
- owner: mesosphere
repo: traefik-forward-auth
branch: master
plateforms: linux/amd64,linux/arm64
env:
REPOSITORY: ${{ matrix.owner }}/${{ matrix.repo }}
IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.repo }}
steps:
- name: Checkout project repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: ${{ matrix.branch }}
- name: Check if image already exists
id: check
if: (github.event_name == 'schedule') && (env.REGISTRY == 'ghcr.io')
continue-on-error: true
run: |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
RESP=$(curl -H "Authorization: Bearer $GHCR_TOKEN" https://ghcr.io/v2/${{ env.IMAGE_NAME }}/tags/list)
echo $RESP | jq .tags | grep sha-$(git rev-parse --short HEAD)
- name: Checkout containers repository
if: steps.check.outcome != 'success'
uses: actions/checkout@v4
with:
path: containers
- name: Apply .diff and set Dockerfile
if: steps.check.outcome != 'success'
id: prepare
run: |
DIFF="containers/${{ matrix.repo }}.diff"
if [ -f $DIFF ]; then
echo Applying $DIFF
git apply $DIFF
fi
CUSTOM_DOCKERFILE="containers/${{ matrix.repo }}.Dockerfile"
if [ -f "$CUSTOM_DOCKERFILE" ]; then
DOCKERFILE=$CUSTOM_DOCKERFILE
elif [ -n "${{ matrix.dockerfile }}" ]; then
DOCKERFILE=${{ matrix.dockerfile }}
else
DOCKERFILE=Dockerfile
fi
echo Will use $DOCKERFILE
echo DOCKERFILE=$DOCKERFILE >> $GITHUB_OUTPUT
- name: Install cosign
if: (steps.check.outcome != 'success') && (github.ref == 'refs/heads/main')
uses: sigstore/cosign-installer@v3
- name: Set up QEMU
if: steps.check.outcome != 'success'
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
if: steps.check.outcome != 'success'
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: (steps.check.outcome != 'success') && (github.ref == 'refs/heads/main')
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
if: steps.check.outcome != 'success'
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.branch }}
type=sha
- name: Build and push Docker image
if: steps.check.outcome != 'success'
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ${{ steps.prepare.outputs.DOCKERFILE }}
platforms: ${{ matrix.plateforms }}
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
if: (steps.check.outcome != 'success') && (github.ref == 'refs/heads/main')
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}