Skip to content

Commit 0f4712f

Browse files
committed
add docker CI and publish action
1 parent f3137a3 commit 0f4712f

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.github/workflows/docker-ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build image
16+
run: |
17+
COMMIT_HASH=$(git rev-parse --short HEAD)
18+
IMAGE_TAG=ghcr.io/${{ github.repository }}:${COMMIT_HASH}
19+
docker build . --file Dockerfile --tag $IMAGE_TAG
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Docker publish
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Login to ghcr
18+
uses: docker/login-action@v3
19+
with:
20+
registry: ${{ env.REGISTRY }}
21+
username: ${{ github.actor }}
22+
password: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Extract metadata for image tag
25+
id: meta
26+
uses: docker/metadata-action@v4
27+
with:
28+
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
29+
30+
- name: Build and push image
31+
uses: docker/build-push-action@v5
32+
with:
33+
context: .
34+
push: true
35+
tags: ${{ steps.meta.outputs.tags }}
36+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rust
1+
name: Rust CI
22

33
on:
44
push:

0 commit comments

Comments
 (0)