Skip to content

Commit 1d80574

Browse files
Add github container registry
1 parent 1a26cd7 commit 1d80574

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,46 @@ on:
1616

1717
# TODO: test vars in-line vs. global env
1818
env:
19-
docker_user: ${{ secrets.DOCKERHUB_USERNAME }}
19+
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
20+
GHCR_USER: ${{ github.actor }}
2021
app_name: ${{ vars.APP_NAME }}
2122

2223
jobs:
24+
ghcr:
25+
strategy:
26+
fail-fast: true
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
- name: Docker meta
32+
id: meta
33+
uses: docker/metadata-action@v4
34+
with:
35+
images: |
36+
${{ env.GHCR_USER }}/${{ env.app_name }}
37+
tags: |
38+
type=schedule
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=semver,pattern={{version}}
42+
type=semver,pattern={{major}}.{{minor}}
43+
type=semver,pattern={{major}}
44+
type=sha
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v1
47+
with:
48+
registry: ghcr.io
49+
username: ${{ env.GHCR_USER }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v4
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
2359
docker:
2460
strategy:
2561
fail-fast: true
@@ -32,9 +68,8 @@ jobs:
3268
uses: docker/metadata-action@v4
3369
with:
3470
# list of Docker images to use as base name for tags
35-
# TODO: see above ^^
3671
images: |
37-
${{ env.docker_user }}/${{ env.app_name }}
72+
${{ env.DOCKER_USER }}/${{ env.app_name }}
3873
# generate Docker tags based on the following events/attributes
3974
tags: |
4075
type=schedule

0 commit comments

Comments
 (0)