Skip to content

Commit

Permalink
chore(docker): use docker meta for tagging for GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Sep 25, 2021
1 parent d3140ed commit 081b2d2
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docker-hub:
name: Docker Hub
docker:
name: Docker Build and Push
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/git-cliff:latest
ghcr.io/${{ github.repository_owner }}/git-cliff:latest
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -26,20 +42,30 @@ jobs:
${{ runner.os }}-buildx-
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/git-cliff:latest
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

Expand Down

0 comments on commit 081b2d2

Please sign in to comment.