Skip to content

Commit 08399f0

Browse files
authored
Merge pull request #1 from ce-rust/feature/publish-to-ghcr
publish to ghcr.io
2 parents 3927cea + 99d59e5 commit 08399f0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/build-push.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Create and publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
branches:
9+
- 'master'
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ce-rust/rust-cerk
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
- name: Log in to the Container registry
25+
if: github.event_name != 'pull_request'
26+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
- name: Build and push Docker image
37+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
38+
with:
39+
context: .
40+
push: ${{ github.event_name != 'pull_request' }}
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)