Skip to content

Commit 1361cb3

Browse files
authored
Merge pull request #393 from stratosphereips/ondrej-lukas-add-docker-workflow
Add GitHub Actions workflow for Docker publishing
2 parents 4de09a9 + 4638dc5 commit 1361cb3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
# Optional: Trigger on tag creation (e.g., v1.0, v2.0)
7+
tags: [ 'v*.*.*' ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
env:
12+
# Use your Docker Hub username and repo name here
13+
# Format: username/repository-name
14+
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/netsecgame
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
# Set up QEMU (Optional: only needed if you want to build for multiple architectures like ARM64)
28+
# - name: Set up QEMU
29+
# uses: docker/setup-qemu-action@v3
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Log in to Docker Hub
35+
uses: docker/login-action@v3
36+
with:
37+
username: ${{ secrets.DOCKERHUB_USERNAME }}
38+
password: ${{ secrets.DOCKERHUB_TOKEN }}
39+
40+
# This step extracts metadata (tags, labels) for Docker
41+
- name: Extract Docker metadata
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
type=ref,event=branch
49+
type=ref,event=tag
50+
type=sha
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@v5
54+
with:
55+
context: .
56+
push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs, just build
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)