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
|
2022-03-02 14:19:44 +01:00
|
|
|
uses: actions/checkout@v3
|
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:25:40 +02:00
|
|
|
if: github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/pull') && github.actor != "dependabot[bot]"
|
2022-05-06 18:53:15 +02:00
|
|
|
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
|
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
|
2022-05-05 15:12:37 +02:00
|
|
|
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
|
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
|
2022-05-06 15:11:05 +02:00
|
|
|
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8
|
2021-06-18 09:49:19 +02:00
|
|
|
with:
|
|
|
|
context: .
|
2022-05-06 19:25:40 +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 }}
|