Cleanup preview env workflow variables (#25160)
* cleanup staging action vars, prep for OS deploy workflow * fix app_url
This commit is contained in:
@@ -36,7 +36,7 @@ for (const file of articleFiles) {
|
||||
const sourceUrl = file.blob_url
|
||||
const fileName = file.filename.slice(pathPrefix.length)
|
||||
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
|
||||
const previewLink = `https://${APP_URL}/${fileUrl}`
|
||||
const previewLink = `${APP_URL}/${fileUrl}`
|
||||
const productionLink = `https://docs.github.com/${fileUrl}`
|
||||
let markdownLine = ''
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
[[ -z $GITHUB_ENV ]] && { echo "Missing GITHUB_ENV. Exiting."; exit 1; }
|
||||
[[ -z $APP_NAME_SEED ]] && { echo "Missing APP_NAME_SEED. Exiting."; exit 1; }
|
||||
|
||||
RESOURCE_GROUP="docs-nonprod"
|
||||
echo "RESOURCE_GROUP=${RESOURCE_GROUP}" >> $GITHUB_ENV
|
||||
PREVIEW_ENV_LOCATION="eastus"
|
||||
echo "PREVIEW_ENV_LOCATION=${PREVIEW_ENV_LOCATION}" >> $GITHUB_ENV
|
||||
|
||||
REPO_NAME="${GITHUB_REPOSITORY#*\/}"
|
||||
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
|
||||
@@ -30,7 +30,7 @@ APP_SHA=$(echo -n "${APP_NAME_SEED}-${APP_NAME_BASE}" | sha1sum | cut -c1-6)
|
||||
APP_NAME="${APP_NAME_BASE}-${APP_SHA}"
|
||||
echo "APP_NAME=${APP_NAME}" >> $GITHUB_ENV
|
||||
|
||||
APP_URL="https://${APP_NAME}.eastus.azurecontainer.io"
|
||||
APP_URL="https://${APP_NAME}.${PREVIEW_ENV_LOCATION}.azurecontainer.io"
|
||||
echo "APP_URL=${APP_URL}" >> $GITHUB_ENV
|
||||
|
||||
IMAGE_REPO="${GITHUB_REPOSITORY}/pr-${PR_NUMBER}"
|
||||
|
||||
16
.github/workflows/azure-preview-env-deploy.yml
vendored
16
.github/workflows/azure-preview-env-deploy.yml
vendored
@@ -47,8 +47,6 @@ jobs:
|
||||
url: ${{ env.APP_URL }}
|
||||
env:
|
||||
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' }}
|
||||
|
||||
steps:
|
||||
@@ -61,7 +59,7 @@ jobs:
|
||||
uses: azure/docker-login@81744f9799e7eaa418697cb168452a2882ae844a
|
||||
with:
|
||||
login-server: ${{ secrets.NONPROD_REGISTRY_SERVER }}
|
||||
username: ${{ env.NONPROD_REGISTRY_USERNAME }}
|
||||
username: ${{ secrets.NONPROD_REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.NONPROD_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
@@ -80,7 +78,7 @@ jobs:
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
APP_NAME_SEED: ${{ secrets.APP_NAME_SEED }}
|
||||
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
|
||||
run: .github/actions-scripts/get-preview-app-info.sh
|
||||
|
||||
- name: 'Set env vars'
|
||||
@@ -150,7 +148,7 @@ jobs:
|
||||
# Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel)
|
||||
- name: 'Cancel any existing deployments for this PR'
|
||||
run: |
|
||||
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ env.RESOURCE_GROUP }} || true
|
||||
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} || true
|
||||
|
||||
# Deploy ARM template is idempotent
|
||||
# Note: once the resources exist the image tag must change for a new deployment to occur (the image tag includes workflow run number, run attempt, as well as sha)
|
||||
@@ -158,14 +156,16 @@ jobs:
|
||||
id: deploy
|
||||
uses: azure/arm-deploy@841b12551939c88af8f6df767c24c38a5620fd0d
|
||||
with:
|
||||
resourceGroupName: ${{ env.RESOURCE_GROUP }}
|
||||
resourceGroupName: ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }}
|
||||
subscriptionId: ${{ secrets.NONPROD_SUBSCRIPTION_ID }}
|
||||
template: ./azure-preview-env-template.json
|
||||
deploymentName: ${{ env.DEPLOYMENT_NAME }}
|
||||
parameters: appName="${{ env.APP_NAME }}"
|
||||
location="${{ env.APP_LOCATION }}"
|
||||
location="${{ env.PREVIEW_ENV_LOCATION }}"
|
||||
containerImage="${{ env.DOCKER_IMAGE }}"
|
||||
dockerRegistryUrl="${{ secrets.NONPROD_REGISTRY_SERVER }}"
|
||||
dockerRegistryUsername="${{ env.NONPROD_REGISTRY_USERNAME }}"
|
||||
dockerRegistryUsername="${{ secrets.NONPROD_REGISTRY_USERNAME }}"
|
||||
dockerRegistryPassword="${{ secrets.NONPROD_REGISTRY_PASSWORD }}"
|
||||
# this shows warnings in the github actions console, because the flag is passed through a validation run,
|
||||
# but it *is* functional during the actual execution
|
||||
additionalArguments: --no-wait
|
||||
|
||||
@@ -24,7 +24,6 @@ jobs:
|
||||
timeout-minutes: 5
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER }}
|
||||
NONPROD_REGISTRY_NAME: ghdocs
|
||||
|
||||
steps:
|
||||
- name: 'Az CLI login'
|
||||
@@ -37,25 +36,25 @@ jobs:
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
APP_NAME_SEED: ${{ secrets.APP_NAME_SEED }}
|
||||
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
|
||||
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
|
||||
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} || true
|
||||
|
||||
# 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 container delete -n ${{ env.APP_NAME }} -g ${{ env.RESOURCE_GROUP }} -y
|
||||
az container delete -n ${{ env.APP_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} -y
|
||||
|
||||
# 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
|
||||
- name: 'Untag all docker images for this PR'
|
||||
run: |
|
||||
az acr repository delete -n ${{ env.NONPROD_REGISTRY_NAME }} --repository ${{ env.IMAGE_REPO }} -y || true
|
||||
az acr repository delete -n ${{ secrets.NONPROD_REGISTRY_NAME }} --repository ${{ env.IMAGE_REPO }} -y || true
|
||||
|
||||
# Remove all GitHub deployments from this environment and remove the environment
|
||||
- uses: strumwolf/delete-deployment-environment@45c821e46baa405e25410700fe2e9643929706a0
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
APP_NAME_SEED: ${{ secrets.APP_NAME_SEED }}
|
||||
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
|
||||
run: .github/actions-scripts/get-preview-app-info.sh
|
||||
|
||||
- name: Setup Node
|
||||
|
||||
Reference in New Issue
Block a user