Skip to content

Commit 23bd033

Browse files
committed
Publish landing image to GHCR
1 parent 7e9017e commit 23bd033

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

.github/workflows/container.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish Container
2+
3+
on:
4+
push:
5+
branches:
6+
- expansion
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
publish:
19+
name: Build and publish
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v5
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v4
28+
29+
- name: Log in to GHCR
30+
uses: docker/login-action@v4
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Generate image metadata
37+
id: meta
38+
uses: docker/metadata-action@v6
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=ref,event=branch
43+
type=sha,prefix=sha-
44+
type=raw,value=latest,enable=${{ github.ref_name == 'expansion' }}
45+
46+
- name: Build and push image
47+
uses: docker/build-push-action@v7
48+
with:
49+
context: .
50+
file: ./Dockerfile
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,26 @@ docker compose logs -f
5050
docker compose down
5151
```
5252

53-
For a server, either build this repo directly with Compose or publish the image to a registry such as GitHub Container Registry. Docker Hub is optional; GHCR is usually cleaner here because the code already lives on GitHub. A separate server/infrastructure repo can later pull the published image and route `singha.io` to container port `80`.
53+
On every push to `expansion`, GitHub Actions publishes:
54+
55+
```text
56+
ghcr.io/rgs2151/landing:expansion
57+
ghcr.io/rgs2151/landing:latest
58+
ghcr.io/rgs2151/landing:sha-<commit>
59+
```
60+
61+
A server/infrastructure repository should pull the image instead of copying this source code:
62+
63+
```yaml
64+
services:
65+
landing:
66+
image: ghcr.io/rgs2151/landing:expansion
67+
restart: unless-stopped
68+
expose:
69+
- "80"
70+
```
71+
72+
Route `singha.io` to container port `80`. Docker Hub is optional; GHCR is the default because the code and Actions pipeline already live on GitHub.
5473

5574
## Domain
5675

0 commit comments

Comments
 (0)