ci: use docker/metadata-action instead of deprecated shell-scripts

This commit is contained in:
Frédéric Guillot 2024-03-30 16:47:13 -07:00
parent 194f517be8
commit 6e870cdccc
1 changed files with 33 additions and 59 deletions

View File

@ -8,35 +8,8 @@ on:
pull_request: pull_request:
branches: [ main ] branches: [ main ]
jobs: jobs:
test-docker-images: docker-images:
if: github.event.pull_request name: Docker Images
name: Test Images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Alpine image
uses: docker/build-push-action@v5
with:
context: .
file: ./packaging/docker/alpine/Dockerfile
push: false
tags: ${{ github.repository_owner }}/miniflux:alpine-dev
- name: Test Alpine Docker image
run: docker run --rm ${{ github.repository_owner }}/miniflux:alpine-dev miniflux -i
- name: Build Distroless image
uses: docker/build-push-action@v5
with:
context: .
file: ./packaging/docker/distroless/Dockerfile
push: false
tags: ${{ github.repository_owner }}/miniflux:distroless-dev
- name: Test Distroless Docker image
run: docker run --rm ${{ github.repository_owner }}/miniflux:distroless-dev miniflux -i
publish-docker-images:
if: ${{ ! github.event.pull_request }}
name: Publish Images
permissions: permissions:
packages: write packages: write
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -46,33 +19,31 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Generate Alpine Docker tag - name: Generate Alpine Docker tags
id: docker_alpine_tag id: docker_alpine_tags
run: | uses: docker/metadata-action@v5
DOCKER_IMAGE=${{ github.repository_owner }}/miniflux with:
DOCKER_VERSION=dev images: |
if [ "${{ github.event_name }}" = "schedule" ]; then docker.io/miniflux/miniflux
DOCKER_VERSION=nightly ghcr.io/miniflux/miniflux
TAGS="docker.io/${DOCKER_IMAGE}:${DOCKER_VERSION},ghcr.io/${DOCKER_IMAGE}:${DOCKER_VERSION},quay.io/${DOCKER_IMAGE}:${DOCKER_VERSION}" quay.io/miniflux/miniflux
elif [[ $GITHUB_REF == refs/tags/* ]]; then tags: |
DOCKER_VERSION=${GITHUB_REF#refs/tags/} type=ref,event=pr
TAGS="docker.io/${DOCKER_IMAGE}:${DOCKER_VERSION},ghcr.io/${DOCKER_IMAGE}:${DOCKER_VERSION},quay.io/${DOCKER_IMAGE}:${DOCKER_VERSION},docker.io/${DOCKER_IMAGE}:latest,ghcr.io/${DOCKER_IMAGE}:latest,quay.io/${DOCKER_IMAGE}:latest" type=schedule,pattern=nightly
fi type=semver,pattern={{raw}}
echo ::set-output name=tags::${TAGS}
- name: Generate Distroless Docker tag - name: Generate Distroless Docker tags
id: docker_distroless_tag id: docker_distroless_tags
run: | uses: docker/metadata-action@v5
DOCKER_IMAGE=${{ github.repository_owner }}/miniflux with:
DOCKER_VERSION=dev-distroless images: |
if [ "${{ github.event_name }}" = "schedule" ]; then docker.io/miniflux/miniflux
DOCKER_VERSION=nightly-distroless ghcr.io/miniflux/miniflux
TAGS="docker.io/${DOCKER_IMAGE}:${DOCKER_VERSION},ghcr.io/${DOCKER_IMAGE}:${DOCKER_VERSION},quay.io/${DOCKER_IMAGE}:${DOCKER_VERSION}" quay.io/miniflux/miniflux
elif [[ $GITHUB_REF == refs/tags/* ]]; then tags: |
DOCKER_VERSION=${GITHUB_REF#refs/tags/}-distroless type=ref,event=pr,suffix=-distroless
TAGS="docker.io/${DOCKER_IMAGE}:${DOCKER_VERSION},ghcr.io/${DOCKER_IMAGE}:${DOCKER_VERSION},quay.io/${DOCKER_IMAGE}:${DOCKER_VERSION},docker.io/${DOCKER_IMAGE}:latest-distroless,ghcr.io/${DOCKER_IMAGE}:latest-distroless,quay.io/${DOCKER_IMAGE}:latest-distroless" type=schedule,pattern=nightly,suffix=-distroless
fi type=semver,pattern={{raw}},suffix=-distroless
echo ::set-output name=tags::${TAGS}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -81,12 +52,14 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to DockerHub - name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ghcr.io registry: ghcr.io
@ -94,6 +67,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay Container Registry - name: Login to Quay Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: quay.io registry: quay.io
@ -106,8 +80,8 @@ jobs:
context: . context: .
file: ./packaging/docker/alpine/Dockerfile file: ./packaging/docker/alpine/Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_alpine_tag.outputs.tags }} tags: ${{ steps.docker_alpine_tags.outputs.tags }}
- name: Build and Push Distroless images - name: Build and Push Distroless images
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -115,5 +89,5 @@ jobs:
context: . context: .
file: ./packaging/docker/distroless/Dockerfile file: ./packaging/docker/distroless/Dockerfile
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_distroless_tag.outputs.tags }} tags: ${{ steps.docker_distroless_tags.outputs.tags }}