ci(build-deploy): enable concurrency #114
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Azure Static Web Apps CI/CD | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
branches: ["main"] | |
env: | |
NODE_VERSION: '20.x' | |
jobs: | |
build_and_deploy_job: | |
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | |
runs-on: ubuntu-latest | |
name: Build and Deploy Job | |
environment: ${{ github.event_name == 'push' && 'Production' || 'Staging' }} | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
lfs: false | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install deps | |
run: yarn install --immutable --immutable-cache --check-cache | |
- name: Verify formatting | |
run: yarn lint | |
- name: Build dist | |
run: yarn build | |
- name: Deploy static web app | |
id: deploy | |
uses: Azure/static-web-apps-deploy@v1 | |
env: | |
SKIP_DEPLOY_ON_MISSING_SECRETS: ${{ github.event_name == 'pull_request' }} | |
IS_STATIC_EXPORT: true | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_SWA_TOKEN }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
action: 'upload' | |
app_location: 'out' | |
skip_app_build: true | |
skip_api_build: true | |
close_pull_request_job: | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
name: Close Pull Request Job | |
steps: | |
- name: Close pull request | |
id: closepullrequest | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_SWA_TOKEN }} | |
action: 'close' | |
app_location: '' |