Skip to content

feat: 2024 update

feat: 2024 update #18

name: Build and push docker image
on:
push:
tags: ["v*"]
env:
IMAGE_NAME: ${{ github.repository }}
GHCR: ghcr.io
jobs:
build_and_push:
name: Push Docker image to Docker Hub + ghcr
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: |
# DockerHub
${{ env.IMAGE_NAME }}
# GHCR
${{ env.GHCR }}/${{ env.IMAGE_NAME }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}