2020-07-17 11:04:46 +08:00
|
|
|
name: docker
|
2020-07-17 09:08:59 +08:00
|
|
|
|
2020-07-17 11:13:31 +08:00
|
|
|
on: [push, pull_request]
|
2020-07-17 09:08:59 +08:00
|
|
|
|
2021-10-26 13:49:14 +08:00
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
2020-07-17 09:08:59 +08:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
runs-on: ubuntu-latest
|
2021-10-26 13:49:14 +08:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2020-07-17 09:08:59 +08:00
|
|
|
steps:
|
|
|
|
- name: Check out code into the Go module directory
|
2021-10-26 13:20:09 +08:00
|
|
|
uses: actions/checkout@v2.3.5
|
2021-10-26 13:49:14 +08:00
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@latest
|
2020-07-17 09:08:59 +08:00
|
|
|
with:
|
2021-10-26 13:49:14 +08:00
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2020-07-17 09:08:59 +08:00
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-26 13:49:14 +08:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@latest
|
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
- name: Build and push Docker image
|
|
|
|
uses: docker/build-push-action@2.7.0
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|