Push to ghcr.io

This commit is contained in:
Leonard Jonathan Oh 2023-03-13 15:59:26 +00:00
parent f1d1c175f9
commit 7ac893b179
2 changed files with 20 additions and 0 deletions

View file

@ -1,13 +1,21 @@
name: docker
on:
push:
branches:
- master
tags:
- '**'
# TODO: Remove this before merging PR
pull_request:
branches:
- master
# This is needed to push to GitHub Container Registry. See https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
@ -16,12 +24,14 @@ jobs:
uses: actions/checkout@v3
# This step generates the docker tags
# TODO: Remove type=ref,event=pr before merging PR
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
# type=ref,event=pr generates tag(s) on PRs only. E.g. 'pr-123', 'pr-123-abc0123'
# type=ref,event=branch generates tag(s) on branch only. E.g. 'master', 'master-abc0123'
# type=ref,event=tag generates tag(s) on tags only. E.g. 'v0.0.0', 'v0.0.0-abc0123', and 'latest'
@ -55,6 +65,13 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build-and-push
uses: docker/build-push-action@v3