Skip to content

Commit f673180

Browse files
authored
Merge pull request #2 from swiss-ai/ci/trigger-readme-cleanup
rename workflows and add release
2 parents f4bb819 + a0aa428 commit f673180

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

.github/workflows/merge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CD
1+
name: Merge
22

33
on:
44
push:

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: PR
22

33
on:
44
pull_request:

.github/workflows/release.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
packages: write
10+
11+
jobs:
12+
validate-tag:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Validate semver tag
16+
run: |
17+
TAG="${{ github.event.release.tag_name }}"
18+
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
19+
echo "::error::Tag '$TAG' is not valid semver (expected vX.Y.Z)"
20+
exit 1
21+
fi
22+
23+
retag-images:
24+
runs-on: ubuntu-latest
25+
needs: [validate-tag]
26+
strategy:
27+
matrix:
28+
image: [backend, frontend]
29+
steps:
30+
- uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Re-tag ${{ matrix.image }} image with release version
36+
run: |
37+
SRC="ghcr.io/${{ github.repository }}/${{ matrix.image }}:${{ github.sha }}"
38+
DST="ghcr.io/${{ github.repository }}/${{ matrix.image }}:${{ github.event.release.tag_name }}"
39+
docker pull "$SRC"
40+
docker tag "$SRC" "$DST"
41+
docker push "$DST"
42+
43+
deploy:
44+
runs-on: ubuntu-latest
45+
needs: [retag-images]
46+
steps:
47+
- uses: actions/checkout@v5
48+
with:
49+
repository: breithorn-poc/rob-poc
50+
token: ${{ secrets.ARGO_PAT }}
51+
path: argocd
52+
- name: Update prod image tags
53+
run: |
54+
TAG="${{ github.event.release.tag_name }}"
55+
sed -i "s|image: ghcr.io/swiss-ai/serving-api/backend:.*|image: ghcr.io/swiss-ai/serving-api/backend:$TAG|" argocd/serving-api/prod/backend-deployment.yaml
56+
sed -i "s|image: ghcr.io/swiss-ai/serving-api/frontend:.*|image: ghcr.io/swiss-ai/serving-api/frontend:$TAG|" argocd/serving-api/prod/frontend-deployment.yaml
57+
- name: Commit and push
58+
run: |
59+
cd argocd
60+
git config user.name "github-actions[bot]"
61+
git config user.email "github-actions[bot]@users.noreply.github.com"
62+
git add serving-api/prod/
63+
git diff --staged --quiet && echo "No changes to deploy" || (git commit -m "release serving-api ${{ github.event.release.tag_name }}" && git push)

0 commit comments

Comments
 (0)