-
Notifications
You must be signed in to change notification settings - Fork 210
212 lines (212 loc) · 8.09 KB
/
deploy-pm4.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: BUILD-PM4
on:
#push:
# branches:
# - kr-github-actions
pull_request:
types: [opened, reopened, synchronize, edited, closed]
schedule:
- cron: '30 2 * * *' # every day at midnight
#workflow_dispatch:
#pull_request:
# branches:
# - main
workflow_dispatch:
workflow_call:
env:
SHA: ${{github.event.pull_request.head.sha}}
PROJECT: ${{github.event.pull_request.head.repo.name}}
CI_PR_BODY: ${{ github.event_name == 'schedule' && 'ci:deploy' || github.event.pull_request.body }}
PACKAGE_URL: ${{github.event.pull_request.head.repo.ssh_url}}
PACKAGE_BRANCH: ${{github.event.pull_request.head.ref}}
#MY_GITHUB_TOKEN: ${{ secrets.GH_STATUS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
#GIT_TOKEN: ${{ secrets.MY_GH_TOKEN }}
OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
#Other Parameters
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
aws-url: ${{ secrets.AWS_URL }}
STM_TOKEN: ${{ secrets.STM_TOKEN }}
CI_PACKAGE_BRANCH: ${{github.event.pull_request.head.ref || 'develop' }}
CI_PROJECT: ${{github.event.pull_request.head.repo.name || 'processmaker' }}
CI_TEST: $CI_PROJECT
IMAGE_TAG1: $(echo "$CI_PROJECT-$CI_PACKAGE_BRANCH" | sed "s;/;-;g")
GITHUB_COMMENT: ${{ secrets.GH_COMMENT }}
pull_req_id: ${{github.event.pull_request.number}}
BASE: ${{ contains(github.event.pull_request.body, 'ci:next') && 'ci-base-php82' || 'ci-base' }}
CDATA_LICENSE_DOCUSIGN: ${{ secrets.CDATA_LICENSE_DOCUSIGN }}
CDATA_LICENSE_EXCEL: ${{ secrets.CDATA_LICENSE_EXCEL }}
CDATA_LICENSE_GITHUB: ${{ secrets.CDATA_LICENSE_GITHUB }}
CDATA_LICENSE_SLACK: ${{ secrets.CDATA_LICENSE_SLACK }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
job1:
name: build-stm-image
if: github.event.action != 'closed'
runs-on: ${{ vars.RUNNER }}
steps:
- name: Export Params
run: |
echo "Env Check: CI_PROJECT: $CI_PROJECT CI_PACKAGE_BRANCH: $CI_PACKAGE_BRANCH CI_PR_BODY: $CI_PR_BODY"
echo "REPOSITORY=${{env.aws-url}}/enterprise" >> $GITHUB_ENV
echo "TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE=${{env.aws-url}}/enterprise:${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
#Additional
echo "CACHEBUSTER="$(date +%s) >> $GITHUB_ENV
- name: Clone Repo STM
run: |
git clone --depth 1 -b cicd "https://[email protected]/ProcessMaker/pm4-stm-docker.git" pm4-stm-docker
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.aws-access-key-id }}
aws-secret-access-key: ${{ env.aws-secret-access-key }}
aws-region: ${{ env.aws-region }}
- name: Login to ECR
run: |
aws ecr get-login-password | docker login --username AWS --password-stdin ${{env.aws-url}}
- name: Build and Push the base images
if: contains(github.event.pull_request.body, 'ci:build-base') || github.event_name == 'schedule'
run: |
cd pm4-stm-docker
docker-compose build --no-cache base-php82
docker-compose build --no-cache cache
docker push ${REPOSITORY}:ci-base-php82
docker push ${REPOSITORY}:ci-cache
- name: Build and Push the image to ECR
run: |
cd pm4-stm-docker
docker-compose build processmaker
docker push ${IMAGE}
job2:
name: deploy-stm
if: github.event.action != 'closed'
needs: job1
runs-on: ${{ vars.RUNNER }}
container:
image: cimg/php:7.4
options: --user root
steps:
- name: Export Params
run: |
echo "Env Check: CI_PROJECT: $CI_PROJECT CI_PACKAGE_BRANCH: $CI_PACKAGE_BRANCH CI_PR_BODY: $CI_PR_BODY"
echo "REPOSITORY=${{env.aws-url}}/enterprise" >> $GITHUB_ENV
echo "TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE_TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE=${{env.aws-url}}/enterprise:${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "STM_TOKEN=${{env.STM_TOKEN}}" >> $GITHUB_ENV
- name: Clone Repo STM
run: |
git clone --depth 1 -b cicd "https://[email protected]/ProcessMaker/pm4-stm-docker.git" pm4-stm-docker
cd pm4-stm-docker
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.aws-access-key-id }}
aws-secret-access-key: ${{ env.aws-secret-access-key }}
aws-region: ${{ env.aws-region }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Deploy STM
id: stm
run: |
mkdir -p /tmp/workspace
cd pm4-stm-docker/deploy-stm
composer install --no-dev
php run.php
if [ -f "url.txt" ]; then
INSTANCE_URL=$(cat url.txt)
fi
echo "Instance URL: '${INSTANCE_URL}'"
echo "INSTANCE_URL=${INSTANCE_URL}" >> "$GITHUB_ENV"
- name: Publish the URL to the Github PR
if: success() || steps.stm.conclusion == 'success'
run: |
cd pm4-stm-docker
echo "Instance URL: '${INSTANCE_URL}'"
bash ./github_comment.sh "$PROJECT" "$pull_req_id"
job3:
name: run-phpunit
if: github.event.action != 'closed'
needs: job1
runs-on: ${{ vars.RUNNER }}
steps:
- name: Export Params
run: |
echo "REPOSITORY=${{env.aws-url}}/enterprise" >> $GITHUB_ENV
echo "TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE=${{env.aws-url}}/enterprise:${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
- name: Clone Repo STM
run: |
git clone --depth 1 -b cicd "https://[email protected]/ProcessMaker/pm4-stm-docker.git" pm4-stm-docker
cd pm4-stm-docker
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.aws-access-key-id }}
aws-secret-access-key: ${{ env.aws-secret-access-key }}
aws-region: ${{ env.aws-region }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: PHPUnits
run: |
cd pm4-stm-docker
docker pull $IMAGE
docker-compose down -v
docker-compose build phpunit
docker-compose run phpunit
#job4:
# name: run-benchmarks
# needs: job2
# runs-on: ${{ vars.RUNNER }}
# steps:
# - name: my-step
# run: |
# echo "Fifth Step"
#job5:
# name: run-cypress
# needs: job2
# runs-on: ${{ vars.RUNNER }}
# steps:
# - name: my-step
# run: |
# echo "fourth Step"
#job6:
# name: run-cypress-qa
# needs: job2
# runs-on: ${{ vars.RUNNER }}
# steps:
# - name: my-step
# run: |
# echo "Sixt Step"
job7:
name: Delete Instance
if: github.event.action == 'closed'
runs-on: ${{ vars.RUNNER }}
container:
image: cimg/php:7.4
options: --user root
steps:
- name: Export Params
run: |
echo "REPOSITORY=${{env.aws-url}}/enterprise" >> $GITHUB_ENV
echo "TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE_TAG=${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "IMAGE=${{env.aws-url}}/enterprise:${{env.IMAGE_TAG1}}" >> $GITHUB_ENV
echo "STM_TOKEN=${{env.STM_TOKEN}}" >> $GITHUB_ENV
- name: Clone Repo STM
run: |
git clone --depth 1 -b cicd "https://[email protected]/ProcessMaker/pm4-stm-docker.git" pm4-stm-docker
cd pm4-stm-docker
- name: Delete Instance STM
run: |
mkdir -p /tmp/workspace
cd pm4-stm-docker/deploy-stm
composer install --no-dev
php run-delete-instance.php