Skip to content

Update README.md to enhance project description and clarify usage instructions (create-vertex-app) #1357

Update README.md to enhance project description and clarify usage instructions (create-vertex-app)

Update README.md to enhance project description and clarify usage instructions (create-vertex-app) #1357

name: deploy-to-azure-preview-environment
on:
pull_request_target:
branches:
- staging
env:
RG: airqo-main-rg
LOCATION: westeurope
PR_PREVIEW_ENV: airqo-pr-preview-env
REGISTRY_URL: airqoacr.azurecr.io
KEYVAULT: airqo-kv-staging
jobs:
#########################################
# FORMAT BRANCH NAME
#########################################
branch-name:
runs-on: ubuntu-latest
outputs:
lowercase: ${{ steps.string.outputs.lowercase }}
sanitized: ${{ steps.sanitize.outputs.sanitized }}
steps:
- id: string
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.head_ref || github.ref_name }}
- name: sanitize branch name
id: sanitize
env:
RAW: ${{ steps.string.outputs.lowercase }}
run: |
SANITIZED=$(echo "$RAW" | sed 's/[^a-z0-9]/-/g; s/-\+/-/g; s/^-//; s/-$//')
if [ -z "$SANITIZED" ]; then
SANITIZED="pr${{ github.event.pull_request.number }}"
fi
if [[ ! "$SANITIZED" =~ ^[a-z] ]]; then
SANITIZED="a${SANITIZED}"
fi
SANITIZED="${SANITIZED:0:12}"
SANITIZED="${SANITIZED%-}"
echo "sanitized=$SANITIZED" >> $GITHUB_OUTPUT
#########################################
# DETECT CHANGED SERVICES
#########################################
check:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
run_calibrate_app: ${{ steps.check_files.outputs.run_calibrate_app }}
run_website: ${{ steps.check_files.outputs.run_website }}
run_vertex: ${{ steps.check_files.outputs.run_vertex }}
run_beacon: ${{ steps.check_files.outputs.run_beacon }}
run_docs: ${{ steps.check_files.outputs.run_docs }}
run_nexus: ${{ steps.check_files.outputs.run_nexus }}
steps:
- name: check modified frontends
id: check_files
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "=============== list modified files ==============="
gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files \
--paginate --jq '.[].filename' | tee files.txt
echo "run_calibrate_app=false" >>$GITHUB_OUTPUT
echo "run_website=false" >>$GITHUB_OUTPUT
echo "run_vertex=false" >>$GITHUB_OUTPUT
echo "run_beacon=false" >>$GITHUB_OUTPUT
echo "run_docs=false" >>$GITHUB_OUTPUT
echo "run_nexus=false" >>$GITHUB_OUTPUT
while IFS= read -r file
do
echo $file
if [[ $file == src/calibrate/* ]]; then
echo "run_calibrate_app=true" >>$GITHUB_OUTPUT
fi
if [[ $file == src/nexus/* ]]; then
echo "run_nexus=true" >>$GITHUB_OUTPUT
fi
if [[ $file == src/website/* ]]; then
echo "run_website=true" >>$GITHUB_OUTPUT
fi
if [[ $file == src/vertex/* ]]; then
echo "run_vertex=true" >>$GITHUB_OUTPUT
fi
if [[ $file == src/beacon/* ]]; then
echo "run_beacon=true" >>$GITHUB_OUTPUT
fi
if [[ $file == src/docs-website/* ]]; then
echo "run_docs=true" >>$GITHUB_OUTPUT
fi
done < files.txt
#########################################
# WEBSITE PREVIEW
#########################################
website:
needs: [check, branch-name]
if: needs.check.outputs.run_website == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Login to ACR
run: az acr login --name airqoacr
- name: Build website image
run: |
cd src/website/
docker build . \
--build-arg API_URL=${{ secrets.WEBSITE_STAGE_API_URL }} \
--build-arg NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_GA_MEASUREMENT_ID }} \
--build-arg NEXT_PUBLIC_HCAPTCHA_SITE_KEY=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_HCAPTCHA_SITE_KEY }} \
--build-arg NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN }} \
--build-arg NEXT_PUBLIC_SITE_URL=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_SITE_URL }} \
--tag ${{ env.REGISTRY_URL }}/website-pr-preview:${{ github.event.pull_request.head.sha }}
docker push ${{ env.REGISTRY_URL }}/website-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-website-preview"
ENV_VARS="SECRET=${{ secrets.WEBSITE_SECRET }} API_URL=${{ secrets.WEBSITE_STAGE_API_URL }} OPENCAGE_API_KEY=${{ secrets.WEBSITE_STAGE_OPENCAGE_API_KEY }} API_TOKEN=${{ secrets.WEBSITE_STAGE_API_TOKEN }} SLACK_WEBHOOK_URL=${{ secrets.WEBSITE_STAGE_SLACK_WEBHOOK_URL }} SLACK_CHANNEL=${{ secrets.WEBSITE_STAGE_SLACK_CHANNEL }} NEXT_PUBLIC_HCAPTCHA_SITE_KEY=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_HCAPTCHA_SITE_KEY }} NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN }} NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_GA_MEASUREMENT_ID }} GOOGLE_SITE_VERIFICATION=${{ secrets.WEBSITE_STAGE_GOOGLE_SITE_VERIFICATION }} NEXT_PUBLIC_SITE_URL=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_SITE_URL }}"
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/website-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 8080 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars $ENV_VARS
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-website-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
website-pr-comment:
needs: [check, website]
if: needs.check.outputs.run_website == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v8
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure website changes available for preview [here](${{ needs.website.outputs.url }})'
})
#########################################
# BEACON PREVIEW
#########################################
beacon:
name: build-push-deploy-beacon-preview
needs: [check, branch-name]
if: needs.check.outputs.run_beacon == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- run: az acr login --name airqoacr
- name: Pull secrets from Key Vault
run: |
az keyvault secret show \
--vault-name ${{ env.KEYVAULT }} \
--name sta-env-beacon-web \
--query value -o tsv > secrets.json
- name: Build image
run: |
docker build -t ${{ env.REGISTRY_URL }}/beacon-pr-preview:${{ github.event.pull_request.head.sha }} src/beacon
docker push ${{ env.REGISTRY_URL }}/beacon-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-beacon-preview"
mapfile -t ENV_VARS < <(jq -r 'to_entries[] | "\(.key)=\(.value|tostring)"' secrets.json)
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/beacon-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 3000 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars "${ENV_VARS[@]}"
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-beacon-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
beacon-pr-comment:
needs: [check, beacon]
if: needs.check.outputs.run_beacon == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure beacon changes available for preview [here](${{ needs.beacon.outputs.url }})'
})
#########################################
# CALIBRATE APP PREVIEW
#########################################
calibrate_app:
name: build-push-deploy-calibrate-app-preview
needs: [check, branch-name]
if: needs.check.outputs.run_calibrate_app == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- run: az acr login --name airqoacr
- name: Pull secrets from Key Vault
run: |
az keyvault secret show \
--vault-name ${{ env.KEYVAULT }} \
--name sta-env-calibrate-app \
--query value -o tsv > secrets.json
- name: Build image
run: |
docker build -t ${{ env.REGISTRY_URL }}/calibrate-app-pr-preview:${{ github.event.pull_request.head.sha }} src/calibrate
docker push ${{ env.REGISTRY_URL }}/calibrate-app-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-calibrate-app-preview"
mapfile -t ENV_VARS < <(jq -r 'to_entries[] | "\(.key)=\(.value|tostring)"' secrets.json)
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/calibrate-app-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 80 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars "${ENV_VARS[@]}"
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-calibrate-app-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
calibrate-pr-comment:
needs: [check, calibrate_app]
if: needs.check.outputs.run_calibrate_app == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure calibrate_app changes available for preview [here](${{ needs.calibrate_app.outputs.url }})'
})
#########################################
# NEXUS PREVIEW
#########################################
nexus:
name: build-push-deploy-nexus-preview
needs: [check, branch-name]
if: needs.check.outputs.run_nexus == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- run: az acr login --name airqoacr
- name: Pull secrets from Key Vault
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-nexus-preview"
DEFAULT_DOMAIN=$(az containerapp env show \
--name ${{ env.PR_PREVIEW_ENV }} \
--resource-group ${{ env.RG }} \
--query properties.defaultDomain -o tsv)
NEXTAUTH_URL="https://$APP.$DEFAULT_DOMAIN"
az keyvault secret show \
--vault-name ${{ env.KEYVAULT }} \
--name sta-env-nexus \
--query value -o tsv > secrets.json
jq -r 'to_entries | .[] | select(.key != "NEXTAUTH_URL" and .key != "NEXTAUTH_URL_INTERNAL" and .key != "NEXTAUTH_COOKIE_DOMAIN" and .key != "AUTH_URL" and .key != "AUTH_TRUST_HOST") | "\(.key)=\(.value|tojson)"' secrets.json > src/nexus/.env
{
echo "NEXTAUTH_URL=$NEXTAUTH_URL"
echo "NEXTAUTH_URL_INTERNAL=$NEXTAUTH_URL"
echo "AUTH_TRUST_HOST=true"
} >> src/nexus/.env
- name: Build image
run: |
docker build -t ${{ env.REGISTRY_URL }}/nexus-pr-preview:${{ github.event.pull_request.head.sha }} src/nexus
docker push ${{ env.REGISTRY_URL }}/nexus-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-nexus-preview"
DEFAULT_DOMAIN=$(az containerapp env show \
--name ${{ env.PR_PREVIEW_ENV }} \
--resource-group ${{ env.RG }} \
--query properties.defaultDomain -o tsv)
NEXTAUTH_URL="https://$APP.$DEFAULT_DOMAIN"
mapfile -t ENV_VARS < <(jq -r 'to_entries[] | select(.key != "NEXTAUTH_URL" and .key != "NEXTAUTH_URL_INTERNAL" and .key != "NEXTAUTH_COOKIE_DOMAIN" and .key != "AUTH_URL" and .key != "AUTH_TRUST_HOST") | "\(.key)=\(.value|tostring)"' secrets.json)
ENV_VARS+=("NEXTAUTH_URL=$NEXTAUTH_URL")
ENV_VARS+=("NEXTAUTH_URL_INTERNAL=$NEXTAUTH_URL")
ENV_VARS+=("AUTH_TRUST_HOST=true")
jq -e '((.NEXTAUTH_SECRET // .AUTH_SECRET) | length > 0)' secrets.json >/dev/null
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/nexus-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 3000 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars "${ENV_VARS[@]}"
az containerapp update \
--name $APP \
--resource-group ${{ env.RG }} \
--replace-env-vars "${ENV_VARS[@]}"
AUTH_STATUS=$(curl -sS -o /tmp/nextauth-providers.json -w "%{http_code}" "$NEXTAUTH_URL/api/auth/providers")
if [ "$AUTH_STATUS" != "200" ]; then
echo "NextAuth providers endpoint returned HTTP $AUTH_STATUS"
cat /tmp/nextauth-providers.json || true
az containerapp logs show \
--name $APP \
--resource-group ${{ env.RG }} \
--tail 80 || true
exit 1
fi
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-nexus-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
nexus-pr-comment:
needs: [check, nexus]
if: needs.check.outputs.run_nexus == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure nexus changes available for preview [here](${{ needs.nexus.outputs.url }})'
})
#########################################
# VERTEX PREVIEW
#########################################
vertex:
name: build-push-deploy-vertex-preview
needs: [check, branch-name]
if: needs.check.outputs.run_vertex == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- run: az acr login --name airqoacr
- name: Pull secrets from Key Vault
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-vertex-preview"
DEFAULT_DOMAIN=$(az containerapp env show \
--name ${{ env.PR_PREVIEW_ENV }} \
--resource-group ${{ env.RG }} \
--query properties.defaultDomain -o tsv)
NEXTAUTH_URL="https://$APP.$DEFAULT_DOMAIN"
az keyvault secret show \
--vault-name ${{ env.KEYVAULT }} \
--name sta-env-vertex \
--query value -o tsv > secrets.json
jq -r 'to_entries | .[] | select(.key != "NEXTAUTH_URL" and .key != "NEXTAUTH_URL_INTERNAL" and .key != "NEXTAUTH_COOKIE_DOMAIN") | "\(.key)=\(.value|tojson)"' secrets.json > src/vertex/.env
{
echo "NEXTAUTH_URL=$NEXTAUTH_URL"
echo "NEXTAUTH_URL_INTERNAL=$NEXTAUTH_URL"
echo "AUTH_TRUST_HOST=true"
} >> src/vertex/.env
- name: Build image
run: |
docker build -t ${{ env.REGISTRY_URL }}/vertex-pr-preview:${{ github.event.pull_request.head.sha }} src/vertex
docker push ${{ env.REGISTRY_URL }}/vertex-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-vertex-preview"
DEFAULT_DOMAIN=$(az containerapp env show \
--name ${{ env.PR_PREVIEW_ENV }} \
--resource-group ${{ env.RG }} \
--query properties.defaultDomain -o tsv)
NEXTAUTH_URL="https://$APP.$DEFAULT_DOMAIN"
mapfile -t ENV_VARS < <(jq -r 'to_entries[] | select(.key != "NEXTAUTH_URL" and .key != "NEXTAUTH_URL_INTERNAL" and .key != "NEXTAUTH_COOKIE_DOMAIN") | "\(.key)=\(.value|tostring)"' secrets.json)
ENV_VARS+=("NEXTAUTH_URL=$NEXTAUTH_URL")
ENV_VARS+=("NEXTAUTH_URL_INTERNAL=$NEXTAUTH_URL")
ENV_VARS+=("AUTH_TRUST_HOST=true")
jq -e '((.NEXTAUTH_SECRET // .AUTH_SECRET) | length > 0)' secrets.json >/dev/null
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/vertex-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 3000 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars "${ENV_VARS[@]}"
az containerapp update \
--name $APP \
--resource-group ${{ env.RG }} \
--replace-env-vars "${ENV_VARS[@]}"
az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query "properties.template.containers[0].env[].name" \
-o tsv | sort
AUTH_STATUS=$(curl -sS -o /tmp/nextauth-providers.json -w "%{http_code}" "$NEXTAUTH_URL/api/auth/providers")
if [ "$AUTH_STATUS" != "200" ]; then
echo "NextAuth providers endpoint returned HTTP $AUTH_STATUS"
cat /tmp/nextauth-providers.json || true
az containerapp logs show \
--name $APP \
--resource-group ${{ env.RG }} \
--tail 80 || true
exit 1
fi
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-vertex-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
vertex-pr-comment:
needs: [check, vertex]
if: needs.check.outputs.run_vertex == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure vertex changes available for preview [here](${{ needs.vertex.outputs.url }})'
})
#########################################
# DOCS PREVIEW
#########################################
docs:
name: build-push-deploy-docs-preview
needs: [check, branch-name]
if: needs.check.outputs.run_docs == 'true'
runs-on: ubuntu-latest
outputs:
url: ${{ steps.preview.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- run: az acr login --name airqoacr
- name: Pull secrets from Key Vault
run: |
az keyvault secret show \
--vault-name ${{ env.KEYVAULT }} \
--name sta-env-docs \
--query value -o tsv > secrets.json
- name: Build image
run: |
docker build -t ${{ env.REGISTRY_URL }}/docs-pr-preview:${{ github.event.pull_request.head.sha }} src/docs-website
docker push ${{ env.REGISTRY_URL }}/docs-pr-preview:${{ github.event.pull_request.head.sha }}
- name: Deploy Container App
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-docs-preview"
mapfile -t ENV_VARS < <(jq -r 'to_entries[] | "\(.key)=\(.value|tostring)"' secrets.json)
az containerapp up \
--name $APP \
--resource-group ${{ env.RG }} \
--environment ${{ env.PR_PREVIEW_ENV }} \
--image ${{ env.REGISTRY_URL }}/docs-pr-preview:${{ github.event.pull_request.head.sha }} \
--target-port 3000 \
--ingress external \
--registry-server ${{ env.REGISTRY_URL }} \
--registry-username airqoacr \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--env-vars "${ENV_VARS[@]}"
- id: preview
run: |
BRANCH="${{ needs.branch-name.outputs.sanitized }}"
APP="${BRANCH}-docs-preview"
URL=$(az containerapp show \
--name $APP \
--resource-group ${{ env.RG }} \
--query properties.configuration.ingress.fqdn -o tsv)
echo "url=https://$URL" >> $GITHUB_OUTPUT
docs-pr-comment:
needs: [check, docs]
if: needs.check.outputs.run_docs == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'New azure docs changes available for preview [here](${{ needs.docs.outputs.url }})'
})