Skip to content

Commit 2f7a229

Browse files
authored
Create publish.yml
1 parent 7aa195f commit 2f7a229

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish workflow
2+
on:
3+
push:
4+
5+
env:
6+
REGISTRY: ghcr.io
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
build:
14+
if: ( github.event_name == 'push' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') ) )
15+
runs-on: ubuntu-latest
16+
outputs:
17+
image: ${{ steps.image-ref.outputs.image }}
18+
image_latest: ${{ steps.image-ref.outputs.image_latest }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to Container registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Create image ref
34+
id: image-ref
35+
run: |
36+
REF=$(git rev-parse --short $GITHUB_SHA)
37+
IMAGE=${{ env.REGISTRY }}/${{ github.repository }}:${REF}
38+
IMAGE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}:latest
39+
40+
echo "image=${IMAGE}" >> $GITHUB_STATE
41+
echo "image_latest=${IMAGE_LATEST}" >> $GITHUB_OUTPUT
42+
43+
echo "${IMAGE}" >> $GITHUB_STEP_SUMMARY
44+
45+
- name: Build and push docker image
46+
uses: docker/build-push-action@v6
47+
with:
48+
file: Dockerfile
49+
push: true
50+
platforms: linux/amd64,linux/arm64,windows/amd64,windows/arm64,darwin/amd64,darwin/arm64,linux/arm/v7,linux/arm/v8,linux/s390x
51+
cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_latest }}
52+
cache-to: type=inline
53+
tags: |
54+
${{ steps.image-ref.outputs.image }}
55+
${{ steps.image-ref.outputs.image_latest }}

0 commit comments

Comments
 (0)