mirror of
https://github.com/2martens/tsw-timetable.git
synced 2026-10-17 07:57:55 +02:00
83 lines
2.6 KiB
YAML
83 lines
2.6 KiB
YAML
name: Docker image
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
uses: ./.github/workflows/build.yaml
|
|
jib:
|
|
needs:
|
|
- build
|
|
if: github.repository_owner == '2martens'
|
|
name: Create and publish Docker image
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
attestations: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: 21
|
|
- name: Setup Gradle
|
|
uses: gradle/gradle-build-action@v2
|
|
with:
|
|
gradle-version: 8.5
|
|
cache-read-only: true
|
|
- name: Create and publish docker image
|
|
if: github.event_name == 'push'
|
|
run: ./gradlew -Prelease.useLastTag=true final jib
|
|
env:
|
|
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
- name: Create and publish docker image
|
|
if: github.event_name == 'pull_request'
|
|
run: ./gradlew snapshot jib
|
|
env:
|
|
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
- name: Extract Jib digest
|
|
id: digest
|
|
run: |
|
|
DIGEST_FILE=${{ github.workspace }}/module-deploy/build/jib-image.digest
|
|
INDEX_DIGEST=$(cat $DIGEST_FILE)
|
|
echo "digest=$INDEX_DIGEST" >> $GITHUB_OUTPUT
|
|
ARCH_DIGESTS=$(docker manifest inspect 2martens/timetable@$INDEX_DIGEST | jq -r '.manifests[].digest')
|
|
n=0
|
|
for d in $ARCH_DIGESTS; do
|
|
echo "arch${n}=$d" >> $GITHUB_OUTPUT
|
|
n=$((n+1))
|
|
done
|
|
- name: Perform docker login
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: docker.io
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
- name: Attest
|
|
uses: actions/attest-build-provenance@v3
|
|
with:
|
|
subject-name: docker.io/2martens/timetable
|
|
subject-digest: ${{ steps.digest.outputs.digest }}
|
|
push-to-registry: true
|
|
- name: Attest first arch
|
|
uses: actions/attest-build-provenance@v3
|
|
with:
|
|
subject-name: docker.io/2martens/timetable
|
|
subject-digest: ${{ steps.digest.outputs.arch0 }}
|
|
push-to-registry: true
|
|
- name: Attest second arch
|
|
uses: actions/attest-build-provenance@v3
|
|
with:
|
|
subject-name: docker.io/2martens/timetable
|
|
subject-digest: ${{ steps.digest.outputs.arch1 }}
|
|
push-to-registry: true
|