summaryrefslogtreecommitdiff
path: root/.github/workflows/docker_build.yml
diff options
context:
space:
mode:
authorIwanIDev <iwan@iwani.dev>2026-03-04 16:09:43 +0000
committerIwanIDev <iwan@iwani.dev>2026-03-04 16:09:43 +0000
commit042bb9063c469406d5f59282ab94e95e8cdf401e (patch)
tree0917c826accad052ffb47d7d60e79febcd4a36d6 /.github/workflows/docker_build.yml
parent1e03595e08608bbb8084c549c2ab91993e035bf1 (diff)
Add containerisation setup
Diffstat (limited to '.github/workflows/docker_build.yml')
-rw-r--r--.github/workflows/docker_build.yml53
1 files changed, 53 insertions, 0 deletions
diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml
new file mode 100644
index 0000000..ea36e7e
--- /dev/null
+++ b/.github/workflows/docker_build.yml
@@ -0,0 +1,53 @@
+name: Build Docker Image
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GitHub Container Registry
+ if: github.event_name != 'pull_request'
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=sha
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Build and push
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max \ No newline at end of file