Skip to content

Commit 00a418f

Browse files
authored
Merge pull request #3 from kagenti/chore/kagenti-publish-workflow
chore: add kagenti publish workflow for gateway image
2 parents 98e4758 + 39964ab commit 00a418f

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Publish Gateway Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- main
9+
- mvp
10+
workflow_dispatch:
11+
12+
# Deny all permissions at workflow level; each job declares only what it needs
13+
permissions: {}
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ghcr.io/kagenti/openshell/gateway
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 45
23+
24+
permissions:
25+
contents: read
26+
packages: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
37+
38+
- name: Log in to ghcr.io
39+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
48+
continue-on-error: true
49+
with:
50+
images: ${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=ref,event=tag
53+
type=sha,prefix={{branch}}-,enable=${{ github.ref_type != 'tag' }}
54+
type=raw,value=latest,enable=${{ (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
55+
56+
- name: Wait before retry
57+
if: steps.meta.outcome == 'failure'
58+
run: |
59+
echo "Metadata extraction failed, retrying in 15s..."
60+
sleep 15
61+
62+
- name: Retry Docker metadata
63+
id: meta_retry
64+
if: steps.meta.outcome == 'failure'
65+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
66+
with:
67+
images: ${{ env.IMAGE_NAME }}
68+
tags: |
69+
type=ref,event=tag
70+
type=sha,prefix={{branch}}-,enable=${{ github.ref_type != 'tag' }}
71+
type=raw,value=latest,enable=${{ (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
72+
73+
- name: Build and push gateway image
74+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
75+
with:
76+
context: .
77+
file: deploy/docker/Dockerfile.images
78+
target: gateway
79+
push: true
80+
platforms: linux/amd64,linux/arm64
81+
tags: ${{ steps.meta_retry.outputs.tags || steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta_retry.outputs.labels || steps.meta.outputs.labels }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)