-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (98 loc) · 3.58 KB
/
deploy-prod.yml
File metadata and controls
105 lines (98 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Deploy Prod
on:
release:
types: [published]
permissions:
contents: read
packages: write
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- name: Validate semver tag
run: |
TAG="${{ github.event.release.tag_name }}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Tag '$TAG' is not valid semver (expected vX.Y.Z)"
exit 1
fi
docker-backend:
runs-on: ubuntu-latest
needs: [validate-tag]
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: backend/Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}/backend:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}/backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
docker-frontend:
runs-on: ubuntu-latest
needs: [validate-tag]
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: frontend/Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}/frontend:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}/frontend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs: [docker-backend, docker-frontend]
steps:
- uses: actions/checkout@v5
with:
repository: breithorn-poc/rob-poc
token: ${{ secrets.ARGO_PAT }}
path: argocd
- name: Update prod image tags
run: |
TAG="${{ github.event.release.tag_name }}"
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
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
- name: Commit and push
run: |
cd argocd
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add serving-api/prod/
git diff --staged --quiet && echo "No changes to deploy" || (git commit -m "release serving-api ${{ github.event.release.tag_name }}" && git push)
notify:
name: Slack Notification
runs-on: ubuntu-latest
needs: [validate-tag, docker-backend, docker-frontend, deploy]
if: always()
steps:
- name: Notify Slack
uses: slackapi/slack-github-action@v2
with:
webhook-type: incoming-webhook
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
payload: |
{
"text": "${{ github.repository }} Release — ${{ contains(needs.*.result, 'failure') && 'FAILED' || 'published' }}\nTag: ${{ github.event.release.tag_name }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"
}