2022-05-24 18:09:09 +00:00
|
|
|
name: Create and publish a Docker image
|
2022-05-24 17:16:34 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-05-24 18:09:09 +00:00
|
|
|
branches: ['main']
|
2022-05-24 17:16:34 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
|
|
|
jobs:
|
2022-05-24 18:09:09 +00:00
|
|
|
build-and-push-image:
|
2022-05-24 17:16:34 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
|
|
|
|
steps:
|
2022-05-24 18:09:09 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3.0.2
|
2022-05-24 17:16:34 +00:00
|
|
|
|
2022-05-24 18:09:09 +00:00
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v2.0.0
|
2022-05-24 17:16:34 +00:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-05-24 18:09:09 +00:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
2022-05-24 17:16:34 +00:00
|
|
|
id: meta
|
2022-05-24 18:09:09 +00:00
|
|
|
uses: docker/metadata-action@v4.0.1
|
2022-05-24 17:16:34 +00:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=sha
|
|
|
|
- name: Build and push Docker image
|
2022-05-24 18:09:09 +00:00
|
|
|
uses: docker/build-push-action@v3.0.0
|
2022-05-24 17:16:34 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2022-05-24 18:26:30 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
2022-05-24 17:16:34 +00:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|