|
| 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