Skip to content

Azure Deploy

Azure Deploy #1763

name: Azure Deploy
on:
schedule:
# minute 0, hour 0 UTC (which is 6pm PST/5pm PDT), any day of month, any month, any day of the week
# if we want to support only Mon - Fri we need to change the check how we look for new changes. Currently we
# check for any new changes in the last 24 hours regardless of day)
- cron: '0 21 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# cancel workflow when a newer version of the workflow is triggered on the same github ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
build-and-deploy-samples:
name: Build and Deploy samples
runs-on: ubuntu-latest
permissions:
# Needed for Azure login
id-token: write
environment: production
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Rush
run: npm install -g @microsoft/rush@$(jq -r '.rushVersion' "rush.json")
- name: Set commit SHA as environment variable
run: echo "REACT_APP_COMMIT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Install Dependencies
run: rush install --max-install-attempts 3
- name: Build Projects
run: rush build
- name: Log in with Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Package Calling Sample Artifact
run: rushx package
working-directory: ./samples/Calling
- name: 'Deploy Calling Sample WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: acs-ui-dev-web-calling-hero
package: ./samples/Calling/dist
- name: Package Chat Sample Artifact
run: rushx package
working-directory: ./samples/Chat
- name: 'Deploy Chat Sample WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: acs-ui-dev-web-chat-hero
package: ./samples/Chat/dist
- name: Package CallWithChat Sample Artifact
run: rushx package
working-directory: ./samples/CallWithChat
- name: 'Deploy CallWithChat Sample WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: acs-ui-dev-web-meeting-hero
package: ./samples/CallWithChat/dist
check_failure:
runs-on: ubuntu-latest
permissions:
issues: write
needs: [build-and-deploy-samples]
if: failure() && github.ref == 'refs/heads/main'
name: File issue if Azure Deployment failed
steps:
# Create a GitHub issue if the Azure Deployment failed when running on the `main` branch
- name: Create issue if Azure Deployment failed
id: create-issue
run: |
# check for an issue that is already open
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/search/issues?q=org:Azure+repo:communication-ui-library+label:AZURE_DEPLOY_FAILURE+state:open > $HOME/ci_issues.json
issue_count=$(jq -r '.total_count' $HOME/ci_issues.json)
if [ $issue_count -gt 0 ]; then
echo "No need to create new issue, one already exists"
else
curl -X POST -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/Azure/communication-ui-library/issues -d '{"title":"Main branch AZURE DEPLOY Failed", "body": "Main AZURE DEPLOY Pipeline has failed. Please investigate: https://github.com/Azure/communication-ui-library/actions/runs/${{ github.run_id }}", "labels":["AZURE_DEPLOY_FAILURE", "status:triage"]}'
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}