Skip to content

Commit 8e9790e

Browse files
Merge pull request #3 from crackedupcorson/feature/publish-to-ghr
publish image to ghcr instead of dockerhub
2 parents e50c7c3 + 1d84849 commit 8e9790e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

.github/workflows/build.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,46 @@ on:
77
tags:
88
- '*'
99

10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
1014
jobs:
1115
build-and-push:
1216
runs-on: ubuntu-latest
1317

1418
steps:
19+
# Checkout the repository
1520
- name: Checkout Repository
1621
uses: actions/checkout@v4
1722

23+
# Set up QEMU for cross-platform builds
1824
- name: Set up QEMU (for cross-platform builds)
1925
uses: docker/setup-qemu-action@v3
2026

27+
# Set up Docker Buildx
2128
- name: Set up Docker Buildx
2229
uses: docker/setup-buildx-action@v3
2330

31+
# Log in to GitHub Container Registry
2432
- name: Log in to Docker Hub
2533
uses: docker/login-action@v3
2634
with:
27-
username: ${{ secrets.DOCKERHUB_USERNAME }}
28-
password: ${{ secrets.DOCKERHUB_TOKEN }}
29-
30-
- name: Extract Image Tag
31-
id: vars
32-
run: echo "IMAGE_TAG=${{ github.run_number }}" >> $GITHUB_ENV
35+
registry: ghcr.io
36+
username: ${{ secrets.GH_USERNAME }}
37+
password: ${{ secrets.GH_PAT }}
38+
39+
# Extract metadata (tags, labels) for Docker
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@v4
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3345

46+
# Build and push Docker image
3447
- name: Build and Push Docker Image
3548
run: |
3649
docker buildx build \
3750
--platform linux/amd64,linux/arm64 \
3851
--push \
39-
-t ciarancorson/prom-garmin-scraper:${{ env.IMAGE_TAG }} \
40-
-t ciarancorson/prom-garmin-scraper:latest .
41-
42-
52+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} .

0 commit comments

Comments
 (0)