Build Docker Images #93
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 Docker Images | |
on: [push, repository_dispatch,workflow_dispatch] | |
jobs: | |
build: | |
name: Publish Docker Image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- amd64 | |
- arm64 | |
steps: | |
- id: fluidd | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
owner: fluidd-core | |
repo: fluidd | |
excludes: prerelease, draft | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
flavor: suffix=-${{ matrix.platform }},latest=true | |
tags: | | |
type=raw,value=${{ steps.fluidd.outputs.release }} | |
labels: | | |
maintainer=maaad | |
org.opencontainers.image.title=fluidd-farm | |
org.opencontainers.image.description=fluidd-core | |
org.opencontainers.image.vendor=fluidd-core | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PUSH_TOKEN }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | |
with: | |
context: . | |
build-args: | | |
FLUIDD_VERSION=${{ steps.fluidd.outputs.release }} | |
file: ./Dockerfile | |
provenance: false | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
post-build: | |
name: Post-build tasks | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- id: fluidd | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
owner: fluidd-core | |
repo: fluidd | |
excludes: prerelease, draft | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PUSH_TOKEN }} | |
- uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository }} | |
flavor: latest=true | |
tags: | | |
type=raw,value=${{ steps.fluidd.outputs.release }} | |
- uses: int128/docker-manifest-create-action@v1 | |
with: | |
tags: ${{ steps.meta.outputs.tags }} | |
suffixes: | | |
-amd64 | |
-arm64 | |
- name: Delete all containers from repository without tags | |
uses: Chizkiyahu/delete-untagged-ghcr-action@v2 | |
with: | |
token: ${{ secrets.PUSH_TOKEN }} | |
repository_owner: ${{ github.repository_owner }} | |
repository: ${{ github.repository }} | |
untagged_only: true | |
owner_type: user | |
- name: Delete workflow runs | |
uses: GitRML/delete-workflow-runs@main | |
with: | |
token: ${{ secrets.PUSH_TOKEN }} | |
retain_days: 1 | |
keep_minimum_runs: 3 |