Skip to content

Fix/change exclusions #8

Fix/change exclusions

Fix/change exclusions #8

Workflow file for this run

name: pr-preview
on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [ main ]
permissions:
id-token: write
contents: read
pull-requests: write # lets the action comment the preview URL
env:
# Standard Azure envs for azure/login
ARM_USE_OIDC: "true"
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# TF_VAR_ prefixes map to OpenTofu/Terraform variables
TF_VAR_client_id: ${{ secrets.AZURE_CLIENT_ID }}
TF_VAR_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
TF_VAR_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
jobs:
deploy-preview:
if: github.event.action != 'closed' && github.actor != 'dependabot[bot]'
concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Azure OIDC login
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Install OpenTofu
uses: opentofu/setup-opentofu@9d84900f3238fab8cd84ce47d658d25dd008be2f # v1
with:
tofu_version: "1.6.0"
- name: Tofu init (read-only — NO apply)
working-directory: tofu
run: tofu init -input=false
- name: Read outputs
id: tfout
working-directory: tofu
run: |
TOKEN=$(tofu output -raw swa_api_token)
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"
- name: Deploy to preview
uses: Azure/static-web-apps-deploy@4d27395796ac319302594769cfe812bd207490b1 # v1
with:
azure_static_web_apps_api_token: ${{ steps.tfout.outputs.token }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # needed for the PR comment
action: upload
app_location: "site"
skip_app_build: true
# no deployment_environment → pull_request context auto-makes a preview env
close-preview:
if: github.event.action == 'closed' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Azure OIDC login
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Install OpenTofu
uses: opentofu/setup-opentofu@9d84900f3238fab8cd84ce47d658d25dd008be2f # v1
with:
tofu_version: "1.6.0"
- name: Tofu init (read-only — NO apply)
working-directory: tofu
run: tofu init -input=false
- name: Read outputs
id: tfout
working-directory: tofu
run: |
TOKEN=$(tofu output -raw swa_api_token)
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"
- name: Close preview environment
uses: Azure/static-web-apps-deploy@4d27395796ac319302594769cfe812bd207490b1 # v1
with:
azure_static_web_apps_api_token: ${{ steps.tfout.outputs.token }}
action: close