Skip to content

Commit d0da40a

Browse files
committed
Add CI/CD workflow for automated Docker image build and publish
1 parent d169c72 commit d0da40a

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

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

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,44 @@ View all available arguments:
205205
java -jar HytaleServer.jar --help
206206
```
207207

208+
## Development
209+
210+
### Building Locally
211+
212+
```bash
213+
docker build -t hytale-server .
214+
```
215+
216+
### CI/CD
217+
218+
This project uses GitHub Actions to automatically build and publish the Docker image to GitHub Container Registry (ghcr.io).
219+
220+
**Triggers:**
221+
222+
- Push to `main` branch
223+
- Version tags (`v*`)
224+
- Pull requests (build only, no push)
225+
226+
**Image Tags:**
227+
228+
| Trigger | Example Tags |
229+
| -------------- | ---------------------------------- |
230+
| Push to `main` | `main`, `sha-abc1234` |
231+
| Tag `v1.2.3` | `1.2.3`, `1.2`, `1`, `sha-abc1234` |
232+
233+
**Publishing a Release:**
234+
235+
```bash
236+
git tag v1.0.0
237+
git push origin v1.0.0
238+
```
239+
240+
The image will be available at:
241+
242+
```
243+
ghcr.io/<username>/hytale-server-docker:latest
244+
```
245+
208246
## Resources
209247

210248
- [Official Hytale Server Manual](https://support.hytale.com/hc/en-us/articles/45326769420827-Hytale-Server-Manual)

0 commit comments

Comments
 (0)