LP-118: Review Apps #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |