-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (102 loc) · 4.6 KB
/
open_pr.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
name: Start reviewapp when PR is opened
on:
pull_request:
types: [ opened, reopened ]
jobs:
start_reviewapp:
name: Start reviewapp
runs-on: ubuntu-latest
steps:
- name: Add comment for start of job
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Starting reviewapp
- name: Log in to Azure
uses: azure/login@v1
with:
creds: '{"clientId":"${{ vars.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ vars.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ vars.ARM_TENANT_ID }}"}'
- name: Deploy review app
id: deploy
env:
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
REF_NAME: ${{ github.head_ref }}
run: |
CI_COMMIT_BRANCH="$REF_NAME"
ENV_SLUG=$(echo "${REF_NAME}" | sed -e 's:[^[:alpha:]|^[:digit:]]:-:g' | sed -e 's/\(.*\)/\L\1/')
tag=":$ENV_SLUG"
az extension add --name containerapp --allow-preview true
az containerapp job start -n portal-dbclone --resource-group rg-ecc-portal-uks-dev --subscription "Essex County Council (Portal)" --image "acreccuksdev.azurecr.io/dbclone" --env-vars "NEW_DB_SUFFIX=${ENV_SLUG}" 'MYSQL_HOST=mariadb-ecc-uks-dev.mariadb.database.azure.com' 'MYSQL_USER=mariadb-root' 'MYSQL_DATABASE=drupal_portal' 'MYSQL_PASSWORD=secretref:mysql-password' --container-name dbclonea --cpu 0.75 --memory 1.5
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
sleep 4m
echo "Creating new revision of Container App"
cat > revision.yml <<EOF
properties:
template:
revisionSuffix: gh${GITHUB_RUN_ID}
scale:
minReplicas: 0
maxReplicas: 1
rules:
- name: "http-rule"
http:
metadata:
concurrentRequests: 40
containers:
- image: acreccuksdev.azurecr.io/portal-nginx-drupal$tag
name: nginx
resources:
cpu: 0.25
memory: 0.5Gi
volumeMounts:
- mountPath: /drupal/web/sites/default/files
volumeName: filesharevol
env:
- name: X_ROBOTS_TAG
value: noindex
probes:
- type: liveness
httpGet:
path: "/dd822309-ae33-4e29-addf-869b07453a06"
port: 80
initialDelaySeconds: 5
periodSeconds: 3
- image: acreccuksdev.azurecr.io/portal-drupal-fpm$tag
name: drupal
resources:
cpu: 0.75
memory: 1.5Gi
volumeMounts:
- mountPath: /drupal/web/sites/default/files
volumeName: filesharevol
- mountPath: /drupal/data/default/private
volumeName: privsharevol
env:
- name: MYSQL_HOST
value: mariadb-ecc-uks-dev.mariadb.database.azure.com
- name: MYSQL_USER
value: mariadb-root
- name: MYSQL_DATABASE
value: drupal_ci_${ENV_SLUG}
- name: MYSQL_PASSWORD
secretRef: mysql-password
- name: OPENID_CONNECT_PARAMS
secretRef: openid-connect-params
probes:
- type: liveness
tcpSocket:
port: 9000
initialDelaySeconds: 5
periodSeconds: 3
EOF
az containerapp revision copy --name portal --resource-group rg-ecc-portal-uks-dev --yaml revision.yml --subscription "Essex County Council (Portal)" | tee revision.json
az containerapp revision label add --no-prompt --resource-group rg-ecc-portal-uks-dev --name portal --label ${ENV_SLUG} --revision portal--gh${GITHUB_RUN_ID} --subscription "Essex County Council (Portal)"
echo "env_slug=${ENV_SLUG}" >> "$GITHUB_OUTPUT"
- name: Add comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Started reviewapp
https://portal---${{ steps.deploy.outputs.env_slug }}.livelyforest-609fad32.uksouth.azurecontainerapps.io/