-
Notifications
You must be signed in to change notification settings - Fork 3
94 lines (82 loc) · 3.44 KB
/
deploy_latest_studio.yml
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
name: Deploy Latest Studio Docker Images (3scale-dev)
on:
workflow_dispatch:
workflow_call:
secrets:
ACCESS_TOKEN:
required: true
GOOGLE_CHAT_WEBHOOK:
required: true
GOOGLE_CHAT_WEBHOOK_ERRORS:
required: true
jobs:
deploy-latest-studio:
name: Deploy Latest Studio Image
runs-on: ubuntu-latest
if: github.repository_owner == 'apicurio'
env:
API_IMAGE: quay.io/apicurio/apicurio-studio
UI_IMAGE: quay.io/apicurio/apicurio-studio-ui
IMAGE_TAG: latest-snapshot
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Get digest (UI)
run: |
docker pull ${{ env.UI_IMAGE }}:${{ env.IMAGE_TAG }}
docker image inspect ${{ env.UI_IMAGE }}:${{ env.IMAGE_TAG }}
STUDIO_UI_DOCKER_IMAGE=$(docker image inspect --format='{{index .RepoDigests 0}}' ${{ env.UI_IMAGE }}:${{ env.IMAGE_TAG }})
echo "STUDIO_UI_DOCKER_IMAGE=$STUDIO_UI_DOCKER_IMAGE" >> $GITHUB_ENV
- name: Echo the Docker Image
run: |
echo " UI image: $STUDIO_UI_DOCKER_IMAGE"
- name: Code Checkout
run: |
mkdir repo
cd repo
git init
git config --global user.name "apicurio-ci"
git config --global user.email "[email protected]"
git remote add origin "https://apicurio-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apicurio/apicurio-3scale-gitops.git"
git fetch
git checkout main
git branch --set-upstream-to=origin/main
git pull
- name: Install yaml-cli
run: |
npm install -g yaml-cli
- name: Update UI Docker Image
run: |
cd repo/applications/apicurio-studio/
yaml set deployment-ui.yaml spec.template.spec.containers.0.image ${{ env.STUDIO_UI_DOCKER_IMAGE }} > deployment-ui-NEW.yaml
rm deployment-ui.yaml
mv deployment-ui-NEW.yaml deployment-ui.yaml
- name: Verify Changed Deployment
run: |
cd repo
echo "---"
cat applications/apicurio-studio/deployment-ui.yaml
echo "---"
- name: Commit Changes
run: |
cd repo
git add .
git commit -m 'Automatic upgrade of Studio container images.'
git push origin main
- name: Slack Notification (Always)
if: always()
run: |
MESSAGE="Studio 3scale DEV environment automatic deployment completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}
- name: Slack Notification (Error)
if: failure()
run: |
MESSAGE="Studio 3scale DEV environment automatic deployment FAILED."
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}