-
Notifications
You must be signed in to change notification settings - Fork 11
133 lines (112 loc) · 4.5 KB
/
build-and-trigger-deploy-review.yaml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Build Images and Deploy to Review
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
build-sdk-react:
name: Build and Push sdk-react
if: startsWith(github.head_ref, 'DEV-')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: werf/actions/install@v2
with:
version: v2.16.2
- name: Log in to GitLab Container Registry
uses: docker/login-action@v3
with:
registry: registry.monite.com
username: ${{ vars.GITLAB_BOT_USERNAME }}
password: ${{ secrets.GITLAB_BOT_ACCESS_TOKEN }}
- name: Build and Push All Images
run: |
. $(werf ci-env github --as-file)
werf export \
--config werf.react.yaml \
--parallel-tasks-limit=-1 \
--repo registry.monite.com/monite/frontend/sdkapp \
--tag registry.monite.com/monite/frontend/sdkapp:%image%-${{ github.sha }}
build-sdk-demo:
name: Build and Push sdk-demo
if: startsWith(github.head_ref, 'DEV-')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: werf/actions/install@v2
with:
version: v2.16.2
- name: Log in to GitLab Container Registry
uses: docker/login-action@v3
with:
registry: registry.monite.com
username: ${{ vars.GITLAB_BOT_USERNAME }}
password: ${{ secrets.GITLAB_BOT_ACCESS_TOKEN }}
- name: Build and Push All Images
run: |
. $(werf ci-env github --as-file)
werf export \
--config werf.demo.yaml \
--parallel-tasks-limit=-1 \
--repo registry.monite.com/monite/frontend/sdkapp \
--tag registry.monite.com/monite/frontend/sdkapp:%image%-${{ github.sha }}
build-sdk-drop-in:
name: Build and Push sdk-drop-in
if: startsWith(github.head_ref, 'DEV-')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: werf/actions/install@v2
with:
version: v2.16.2
- name: Log in to GitLab Container Registry
uses: docker/login-action@v3
with:
registry: registry.monite.com
username: ${{ vars.GITLAB_BOT_USERNAME }}
password: ${{ secrets.GITLAB_BOT_ACCESS_TOKEN }}
- name: Build and Push All Images
run: |
. $(werf ci-env github --as-file)
werf export \
--config werf.drop_in.yaml \
--parallel-tasks-limit=-1 \
--repo registry.monite.com/monite/frontend/sdkapp \
--tag registry.monite.com/monite/frontend/sdkapp:%image%-${{ github.sha }}
trigger-gitlab-deploy:
name: Trigger GitLab Deployment to Review
if: startsWith(github.head_ref, 'DEV-')
runs-on: ubuntu-latest
needs:
- build-sdk-demo
- build-sdk-drop-in
steps:
- name: Trigger GitLab Pipeline Deploy to Review
run: |
REPO="${{ secrets.GITLAB_REPOSITORY }}"
PROJECT_ID="${{ secrets.GITLAB_GROUP_ID }}"
GITLAB_TOKEN="${{ secrets.GITLAB_TRIGGER_TOKEN }}"
SDK_DEMO_WITH_NEXTJS_AND_CLERK_AUTH="sdk-demo-with-nextjs-and-clerk-auth-${{ github.sha }}"
SDK_DEMO_NGINX="sdk-demo-nginx-${{ github.sha }}"
SDK_DROP_IN_NGINX="sdk-drop-in-nginx-${{ github.sha }}"
NORMALIZED_GITHUB_BRANCH=$(echo "${{ github.head_ref }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | cut -c1-63)
echo "sdk-demo-with-nextjs-and-clerk-auth = $SDK_DEMO_WITH_NEXTJS_AND_CLERK_AUTH"
echo "sdk-demo-nginx = $SDK_DEMO_NGINX"
echo "sdk-drop-in-nginx = $SDK_DROP_IN_NGINX"
curl --request POST \
--form token="${GITLAB_TOKEN}" \
--form ref="master" \
--form "variables[GITHUB_SHA]=${{ github.sha }}" \
--form "variables[SDK_DEMO_WITH_NEXTJS_AND_CLERK_AUTH]=${SDK_DEMO_WITH_NEXTJS_AND_CLERK_AUTH}" \
--form "variables[SDK_DEMO_NGINX]=${SDK_DEMO_NGINX}" \
--form "variables[SDK_DROP_IN_NGINX]=${SDK_DROP_IN_NGINX}" \
--form "variables[NORMALIZED_GITHUB_BRANCH]=${NORMALIZED_GITHUB_BRANCH}" \
--form "variables[GITHUB_BRANCH]=${{ github.head_ref }}" \
--form "variables[CI_PIPELINE_SOURCE]=pipeline" \
--form "variables[CI_ACTION]=review_deploy" \
"https://${REPO}/api/v4/projects/${PROJECT_ID}/trigger/pipeline"