Skip to content

Bump actions/download-artifact from 3 to 4 #73

Bump actions/download-artifact from 3 to 4

Bump actions/download-artifact from 3 to 4 #73

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
REGISTRY: "ghcr.io"
NAMESPACE: "deutsche-squad-gemeinschaft/mapvote-bot"
IMAGE: "app"
jobs:
build:
name: "Build Bot"
# Use a generic Ubuntu image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
java-version: 18
distribution: 'oracle'
- name: Build project with Maven
run: mvn -B package --file pom.xml
- name: Stage built package
run: |
mkdir build
ls -l target/
cp target/*.jar build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Build
path: build/
image:
name: "Build Docker image (${{ matrix.platform }})"
# Use a generic Ubuntu image
runs-on: ubuntu-latest
# Require the artifact output of the build step
needs: build
# Use strategy so we can run multiple jobs in parallel
strategy:
# Do not stop other jobs in case one job failed
fail-fast: false
# Define the values for parallel jobs
matrix:
# Build images for multiple architectures
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download build
uses: actions/download-artifact@master
with:
name: Build
path: build/
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: deutsche-squad-gemeinschaft
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
push:
name: "Push Docker images"
# Use a generic Ubuntu image
runs-on: ubuntu-latest
# Require the artifact output of the image step
needs: image
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: deutsche-squad-gemeinschaft
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ steps.meta.outputs.version }}