Fix latest tag not being set #1721
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: '0 3 * * *' | |
workflow_dispatch: | |
jobs: | |
grab-imapfilter-latest: | |
runs-on: ubuntu-latest | |
steps: | |
- id: imapfilter-latest-tag | |
run: | | |
# Can't find an endpoint that returns the latest tag - only | |
# the latest release. And since lefcha doesn't use GitHub's | |
# release feature the tags must be used. | |
tag="$(curl --location --silent https://api.github.com/repos/lefcha/imapfilter/tags | jq -r '.[].name' | head -1)" | |
echo "::set-output name=tag::$tag" | |
outputs: | |
tag: ${{ steps.imapfilter-latest-tag.outputs.tag }} | |
build: | |
needs: grab-imapfilter-latest | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- flavor: | | |
latest=false | |
suffix= | |
args: | |
imapfilter_spec=master | |
- flavor: | | |
latest=false | |
suffix=-tag | |
args: | | |
imapfilter_spec=${{ needs.grab-imapfilter-latest.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v3 | |
with: | |
# Spurious segfaults when compiling | |
# https://github.com/docker/setup-qemu-action/issues/188 | |
image: tonistiigi/binfmt:qemu-v8.1.5 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
flavor: ${{ matrix.flavor }} | |
images: | | |
name=ntnn/imapfilter,enable=${{ github.repository == 'ntnn/docker-imapfilter' && github.ref == 'refs/heads/main' }} | |
name=ghcr.io/${{ github.repository }},enable=true | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=sha | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
if: ${{ github.repository == 'ntnn/docker-imapfilter' && github.ref == 'refs/heads/main' }} | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- uses: docker/build-push-action@v6 | |
with: | |
tags: ${{ steps.meta.outputs.tags }} | |
push: true | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
build-args: ${{ matrix.args }} |