Skip to content

Commit 26b00e0

Browse files
committed
fix: build OCI Image on PR:s, fix formatting in README.md
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@proton.me>
1 parent 0141a38 commit 26b00e0

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/oci-image.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
tags:
88
- 'v*'
9+
pull_request:
910
workflow_dispatch:
1011

1112
permissions:
@@ -16,6 +17,10 @@ jobs:
1617
build-and-push:
1718
name: Build and Push Image
1819
runs-on: ubuntu-24.04
20+
env:
21+
# Push for branch/tag pushes, manual runs, and same-repo PRs. Fork PRs
22+
# only get a read-only GITHUB_TOKEN, so those build without pushing.
23+
CAN_PUSH: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
1924
steps:
2025
- name: Checkout
2126
uses: actions/checkout@v6
@@ -27,6 +32,9 @@ jobs:
2732
uses: docker/setup-buildx-action@v4
2833

2934
- name: Log in to GHCR
35+
# On PRs from forks the GITHUB_TOKEN is read-only and login to GHCR
36+
# would fail, so only log in when we can actually push.
37+
if: env.CAN_PUSH == 'true'
3038
uses: docker/login-action@v4
3139
with:
3240
registry: ghcr.io
@@ -41,6 +49,7 @@ jobs:
4149
tags: |
4250
type=ref,event=branch
4351
type=ref,event=tag
52+
type=ref,event=pr
4453
type=sha,prefix=sha-
4554
type=raw,value=latest,enable={{is_default_branch}}
4655
@@ -49,7 +58,7 @@ jobs:
4958
with:
5059
context: .
5160
file: ./Dockerfile
52-
push: true
61+
push: ${{ env.CAN_PUSH == 'true' }}
5362
platforms: linux/amd64,linux/arm64
5463
tags: ${{ steps.meta.outputs.tags }}
5564
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ This repo publishes a multi-arch OCI image (`linux/amd64`, `linux/arm64`) to Git
3030

3131
- Image: `ghcr.io/better-auth/better-hub`
3232
- Tags:
33-
- `latest` on pushes to `main`
34-
- branch/tag refs (for example `main`, `v1.2.3`)
35-
- `sha-<commit>`
33+
- `latest` on pushes to `main`
34+
- branch/tag refs (for example `main`, `v1.2.3`)
35+
- `sha-<commit>`
3636

3737
Pull and run:
3838

0 commit comments

Comments
 (0)