2020-10-14 23:58:10 +00:00
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-09-15 17:30:17 +00:00
|
|
|
- main
|
|
|
|
- master
|
2020-10-14 23:58:10 +00:00
|
|
|
|
|
|
|
# Publish `v1.2.3` tags as releases.
|
|
|
|
tags:
|
2023-09-15 17:30:17 +00:00
|
|
|
- v*
|
2021-10-22 02:49:10 +00:00
|
|
|
pull_request:
|
2020-10-14 23:58:10 +00:00
|
|
|
|
|
|
|
env:
|
2021-10-22 02:49:10 +00:00
|
|
|
REGISTRY: ghcr.io
|
2022-07-13 19:14:49 +00:00
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
2020-10-14 23:58:10 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
push:
|
2021-10-22 04:09:41 +00:00
|
|
|
permissions:
|
|
|
|
packages: write
|
|
|
|
contents: read
|
2020-10-14 23:58:10 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out code into the Go module directory
|
2024-03-19 01:32:50 +00:00
|
|
|
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
2020-10-14 23:58:10 +00:00
|
|
|
|
2021-10-22 02:49:10 +00:00
|
|
|
# Extract metadata (tags, labels) for Docker
|
|
|
|
# https://github.com/docker/metadata-action
|
|
|
|
- name: Extract Docker metadata
|
|
|
|
id: meta
|
2024-02-07 02:00:16 +00:00
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
2021-10-22 02:49:10 +00:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
2022-07-13 19:14:49 +00:00
|
|
|
|
|
|
|
# This action can be useful if you want to add emulation
|
|
|
|
# support with QEMU to be able to build against more platforms.
|
|
|
|
- name: Set up QEMU
|
2023-09-14 22:33:53 +00:00
|
|
|
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
|
2022-07-13 19:14:49 +00:00
|
|
|
|
|
|
|
# This action will create and boot a builder using
|
|
|
|
# by default the docker-container builder driver.
|
|
|
|
# Recommended for build multi-platform images, export cache, etc.
|
|
|
|
- name: Set up Docker Buildx
|
2024-04-19 01:24:39 +00:00
|
|
|
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
|
2022-07-13 19:14:49 +00:00
|
|
|
|
2021-10-22 04:09:41 +00:00
|
|
|
- name: Log into ${{ env.REGISTRY }}
|
|
|
|
if: github.event_name != 'pull_request'
|
2024-03-19 01:38:12 +00:00
|
|
|
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
|
2021-10-22 04:09:41 +00:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-22 02:49:10 +00:00
|
|
|
|
|
|
|
# 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-03-19 01:38:12 +00:00
|
|
|
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
|
2021-10-22 02:49:10 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|