Skip to content

Commit 8f5698b

Browse files
committed
add auto-build
1 parent 660412c commit 8f5698b

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

.github/workflows/release.yaml

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

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM python:3-alpine@sha256:c38ead8bcf521573dad837d7ecfdebbc87792202e89953ba8b2b83a9c5a520b6
22

3+
LABEL org.opencontainers.image.source="https://github.com/chtime/via"
4+
35
EXPOSE 8000
46

57
WORKDIR /app

resources/deploy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121

2222
containers:
2323
- name: via
24-
image: docker.io/chtime/via
24+
image: ghcr.io/chtime/via:latest
2525
imagePullPolicy: Always
2626
env:
2727
- name: STAGE

0 commit comments

Comments
 (0)