2021-06-18 09:49:19 +02:00
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: docker.io
|
|
|
|
# github.repository as <account>/<repo>
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-12-24 08:24:09 +01:00
|
|
|
uses: actions/checkout@v4
|
2021-06-18 09:49:19 +02:00
|
|
|
|
|
|
|
# Login against a Docker registry except on PR
|
|
|
|
# https://github.com/docker/login-action
|
|
|
|
- name: Log into registry ${{ env.REGISTRY }}
|
2022-05-06 19:27:28 +02:00
|
|
|
if: github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/pull') && github.actor != 'dependabot[bot]'
|
2024-05-28 15:12:11 +02:00
|
|
|
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
|
2021-06-18 09:49:19 +02:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
# Extract metadata (tags, labels) for Docker
|
|
|
|
# https://github.com/docker/metadata-action
|
|
|
|
- name: Extract Docker metadata
|
|
|
|
id: meta
|
2024-02-01 14:57:07 +01:00
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
|
2021-06-18 09:49:19 +02:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
flavor: latest=${{ github.ref == 'refs/heads/master' }}
|
|
|
|
|
|
|
|
# Build and push Docker image with Buildx (don't push on PR)
|
|
|
|
# https://github.com/docker/build-push-action
|
|
|
|
- name: Build and push Docker image
|
2024-06-26 15:24:18 +02:00
|
|
|
uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1
|
2021-06-18 09:49:19 +02:00
|
|
|
with:
|
|
|
|
context: .
|
2022-05-06 19:26:58 +02:00
|
|
|
push: ${{ github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/pull') && github.actor != 'dependabot[bot]' }}
|
2021-06-18 09:49:19 +02:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|