Azure: use shared env setter, fix comment workflow (#25044)
* update azure deployments to use shared env getter, fix content changes table
This commit is contained in:
29
.github/workflows/azure-preview-env-deploy.yml
vendored
29
.github/workflows/azure-preview-env-deploy.yml
vendored
@@ -17,6 +17,11 @@ on:
|
||||
# request creator has permission to access secrets.
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
PR_NUMBER:
|
||||
description: 'PR Number'
|
||||
type: string
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -37,24 +42,12 @@ jobs:
|
||||
name: preview-env-${{ github.event.number }}
|
||||
url: ${{ steps.deploy.outputs.defaultHostName }}
|
||||
env:
|
||||
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
|
||||
PREVIEW_ENV_RESOURCE_GROUPS: 4
|
||||
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER }}
|
||||
NONPROD_REGISTRY_USERNAME: ghdocs
|
||||
APP_LOCATION: eastus
|
||||
ENABLE_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
|
||||
# Image tag is unique to each workflow run so that it always triggers a new deployment
|
||||
DOCKER_IMAGE: ${{ secrets.NONPROD_REGISTRY_SERVER }}/${{ github.repository }}/pr-${{ github.event.number }}:${{ github.event.pull_request.head.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
|
||||
steps:
|
||||
- name: 'Set env vars'
|
||||
id: vars
|
||||
run: |
|
||||
REPO_NAME=${GITHUB_REPOSITORY#*\/}
|
||||
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
|
||||
echo "DEPLOYMENT_NAME=${REPO_NAME}-pr-${GITHUB_EVENT_NUMBER}" >> $GITHUB_ENV
|
||||
echo "RESOURCE_GROUP=preview-env-${REPO_NAME}-$((${GITHUB_EVENT_NUMBER} % ${PREVIEW_ENV_RESOURCE_GROUPS}))" >> $GITHUB_ENV
|
||||
echo "APP_NAME=${REPO_NAME}-preview-${GITHUB_EVENT_NUMBER}" >> $GITHUB_ENV
|
||||
|
||||
- name: 'Az CLI login'
|
||||
uses: azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
|
||||
with:
|
||||
@@ -81,6 +74,14 @@ jobs:
|
||||
- name: Check out LFS objects
|
||||
run: git lfs checkout
|
||||
|
||||
- name: Get preview app info
|
||||
run: .github/actions-scripts/get-preview-app-info.sh
|
||||
|
||||
- name: 'Set env vars'
|
||||
run: |
|
||||
# Image tag is unique to each workflow run so that it always triggers a new deployment
|
||||
echo "DOCKER_IMAGE=${{ secrets.NONPROD_REGISTRY_SERVER }}/${IMAGE_REPO}:${{ github.event.pull_request.head.sha }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
|
||||
|
||||
- if: ${{ env.ENABLE_EARLY_ACCESS }}
|
||||
name: Determine which docs-early-access branch to clone
|
||||
id: 'check-early-access'
|
||||
@@ -155,7 +156,7 @@ jobs:
|
||||
subscriptionId: ${{ secrets.NONPROD_SUBSCRIPTION_ID }}
|
||||
template: ./azure-preview-env-template.json
|
||||
deploymentName: ${{ env.DEPLOYMENT_NAME }}
|
||||
parameters: appName="${{ env.APP_NAME }}"
|
||||
parameters: appName="${{ env.APP_NAME_SHORT }}"
|
||||
location="${{ env.APP_LOCATION }}"
|
||||
linuxFxVersion="DOCKER|${{ env.DOCKER_IMAGE }}"
|
||||
dockerRegistryUrl="https://${{ secrets.NONPROD_REGISTRY_SERVER }}"
|
||||
|
||||
27
.github/workflows/azure-preview-env-destroy.yml
vendored
27
.github/workflows/azure-preview-env-destroy.yml
vendored
@@ -24,41 +24,32 @@ jobs:
|
||||
timeout-minutes: 5
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER }}
|
||||
PREVIEW_ENV_RESOURCE_GROUPS: 4
|
||||
NONPROD_REGISTRY_NAME: ghdocs
|
||||
|
||||
steps:
|
||||
- name: 'Set env vars'
|
||||
id: vars
|
||||
run: |
|
||||
REPO_NAME=${GITHUB_REPOSITORY#*\/}
|
||||
echo "RESOURCE_GROUP=preview-env-${REPO_NAME}-$((${PR_NUMBER} % ${PREVIEW_ENV_RESOURCE_GROUPS}))" >> $GITHUB_ENV
|
||||
echo "DEPLOYMENT_NAME=${REPO_NAME}-pr-${PR_NUMBER}" >> $GITHUB_ENV
|
||||
echo "APP_NAME=${REPO_NAME}-preview-${PR_NUMBER}" >> $GITHUB_ENV
|
||||
echo "IMAGE_REPO=${GITHUB_REPOSITORY}/pr-${PR_NUMBER}" >> $GITHUB_ENV
|
||||
|
||||
- name: 'Az CLI login'
|
||||
uses: azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
|
||||
with:
|
||||
creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }}
|
||||
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
FULL_APP_INFO: 1
|
||||
run: .github/actions-scripts/get-preview-app-info.sh
|
||||
|
||||
# Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel)
|
||||
- name: 'Cancel any in progress deployments'
|
||||
run: |
|
||||
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ env.RESOURCE_GROUP }} || true
|
||||
|
||||
# The full app name is obfuscated by an identifier, so we need to query to find the one for this PR
|
||||
- name: 'Get full app name'
|
||||
id: full-app-name
|
||||
run: |
|
||||
FULL_APP_NAME=$(az webapp list -g ${{ env.RESOURCE_GROUP }} --query "[?tags.DocsAppName == '${{ env.APP_NAME }}'].name | [0]")
|
||||
echo "::set-output name=result::${FULL_APP_NAME}"
|
||||
|
||||
# Delete web app (which will also delete the App Service plan)
|
||||
# This will succeed even if the app doesn't exist / has already been deleted
|
||||
- name: 'Delete App Service App (which will also delete the App Service plan)'
|
||||
run: |
|
||||
az webapp delete -n ${{ steps.full-app-name.outputs.result }} -g ${{ env.RESOURCE_GROUP }}
|
||||
az webapp delete -n ${{ env.APP_NAME_FULL }} -g ${{ env.RESOURCE_GROUP }}
|
||||
|
||||
# Untag all images under this PR's container registry repo - the container registry will automatically remove untagged images.
|
||||
# This will fail if the IMAGE_REPO doesn't exist, but we don't care
|
||||
|
||||
@@ -45,10 +45,22 @@ jobs:
|
||||
needs: PR-Preview-Links
|
||||
if: ${{ needs.PR-Preview-Links.outputs.filterContentDir == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
steps:
|
||||
- name: 'Az CLI login'
|
||||
uses: azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
|
||||
with:
|
||||
creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }}
|
||||
|
||||
- name: check out repo content
|
||||
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
FULL_APP_INFO: 1
|
||||
run: .github/actions-scripts/get-preview-app-info.sh
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
|
||||
with:
|
||||
@@ -57,12 +69,13 @@ jobs:
|
||||
|
||||
- name: Install temporary dependencies
|
||||
run: |
|
||||
npm install --no-save github-slugger
|
||||
npm install --no-save github-slugger --registry https://registry.npmjs.org/
|
||||
|
||||
- name: Get changes table
|
||||
id: changes
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
APP_URL: ${{ env.APP_URL }}
|
||||
run: .github/actions-scripts/content-changes-table-comment.js
|
||||
|
||||
- name: Find content directory changes comment
|
||||
|
||||
Reference in New Issue
Block a user