Skip to content

chore: use azure login action as replacement for basic auth #2652

chore: use azure login action as replacement for basic auth

chore: use azure login action as replacement for basic auth #2652

name: Deploy Documentation (staging)
on:
push:
branches:
- master
paths:
- '.github/workflows/cd-deploy-www-staging.yml'
- 'packages/utilities/fast-color/docs/api-report.md'
- 'packages/utilities/fast-react-wrapper/docs/api-report.md'
- 'packages/web-components/**/docs/api-report.md'
- 'sites/fast-website/**'
- 'sites/website/**'
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- archives/fast-element-1
paths:
- '.github/workflows/cd-deploy-www-staging.yml'
- 'packages/utilities/fast-color/docs/api-report.md'
- 'packages/utilities/fast-react-wrapper/docs/api-report.md'
- 'packages/web-components/**/docs/api-report.md'
- 'sites/fast-website/**'
- 'sites/website/**'
env:
AZURE_WEBAPP_ACTIVE_STAGE_NAME: www-west-app
AZURE_WEBAPP_PASSIVE_STAGE_NAME: www-east-app
AZURE_WEBAPP_BUILD_PATH: sites/website
AZURE_WEBAPP_DIST_PATH: sites/website/build
AZURE_WEBAPP_SLOT_NAME: stage
ARTIFACT_NAME: documentation-site
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@master
- uses: actions/setup-node@v3
with:
node-version: 16.20.0
- name: Install Lerna
run: yarn global add [email protected]
- name: Install package dependencies / prepare workspaces
run: yarn install --frozen-lockfile
- name: Build & Prepare Web Application
run: |
cd ${{ env.AZURE_WEBAPP_BUILD_PATH }}
yarn install
yarn build
cp ../site-utilities/statics/server/package.json ../site-utilities/statics/server/server.js build
cd build
npm i
ls -lta
- uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
download_artifact_for_staging:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
needs: build
steps:
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
deploy_active_region:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
needs: build
steps:
- name: 'Azure Login'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_ACTIVE }}
- name: 'Deploy to Active Azure Region'
uses: azure/webapps-deploy@v2
with:
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_WWW_ACTIVE }}
app-name: ${{ env.AZURE_WEBAPP_ACTIVE_STAGE_NAME }}
package: ${{ env.AZURE_WEBAPP_DIST_PATH }}
slot-name: ${{ env.AZURE_WEBAPP_SLOT_NAME }}
deploy_passive_region:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
needs: build
steps:
- name: 'Azure Login'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_PASSIVE }}
- name: 'Deploy to Passive Azure Region'
uses: azure/webapps-deploy@v2
with:
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_WWW_PASSIVE }}
app-name: ${{ env.AZURE_WEBAPP_PASSIVE_STAGE_NAME }}
package: ${{ env.AZURE_WEBAPP_DIST_PATH }}
slot-name: ${{ env.AZURE_WEBAPP_SLOT_NAME }}
# deploy_pr:
# if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: Deploy PR
# uses: actions/download-artifact@v2
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
# - name: Deploy Documentation
# id: deploypr
# uses: Azure/[email protected]
# continue-on-error: ${{ (github.event_name == 'pull_request' && github.event.action != 'closed') }}
# with:
# azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APP_WWW_PR_TOKEN }}
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# action: 'upload'
# app_location: ${{ env.AZURE_WEBAPP_DIST_PATH }}
# output_location: ''
# skip_app_build: true
destroy_pr:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: 'Azure Login'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_FAST_DESIGN }}
- name: Destroy PR
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APP_WWW_PR_TOKEN }}
action: 'close'
notify:
runs-on: ubuntu-latest
needs: [download_artifact_for_staging, deploy_active_region, deploy_passive_region]
steps:
- name: Notify on Discord
uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_NOTIFICATION_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_NOTIFICATION_WEBHOOK_TOKEN }}
color: '#DE2D6D'
username: 'FAST DevOps Documentation Bot'
message: 'Deployment has completed to Staging on https://github.com/microsoft/fast/actions/workflows/cd-deploy-www-staging.yml'