Skip to content

Commit e907277

Browse files
committed
Add automated container build workflow
This workflow automatically builds and publishes Docker containers to GitHub Container Registry (ghcr.io) when: - Dockerfile changes are pushed - Manually triggered via workflow_dispatch - Monthly (1st of each month) Benefits: - Pre-built containers speed up CI/CD - Containers are publicly available for all users - Automatic monthly rebuilds keep images fresh
1 parent 97db0eb commit e907277

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Publish Container
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths:
7+
- 'Dockerfile'
8+
- '.github/workflows/build-container.yml'
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 0 1 * *' # Monthly rebuild
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}
36+
tags: |
37+
type=raw,value=latest
38+
type=sha,prefix={{branch}}-
39+
40+
- name: Build and push container
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)