Skip to content

test change

test change #15

name: Preproduction Deployment
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [ "main" ] # Adjust if your default branch is different
env:
APP_LOCATION: "/" # Location of your client code
API_LOCATION: "api" # Location of your API source code (optional)
APP_ARTIFACT_LOCATION: "build" # Location where the build artifacts are generated
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_PREPROD_API_TOKEN }} # Preprod SWA deployment token
permissions:
contents: read
pull-requests: write # Needed for posting comments on PRs
jobs:
build_and_deploy:
runs-on: ubuntu-latest
name: Build and Deploy to Preprod SWA
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
with:
submodules: true
# Step 2: Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.18'
# Step 3: Install pnpm
- name: Install pnpm
run: npm install -g pnpm
# Step 4: Use pnpm for workspace setup and build
- name: Install and Build with pnpm
run: |
cd docs
pnpm install --frozen-lockfile
pnpm run build
# Step 5: Deploy to Azure Static Web Apps (Preprod)
- name: Deploy to Azure Static Web Apps (Preprod)
id: deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
action: "upload"
app_location: ${{ env.APP_LOCATION }}
api_location: ${{ env.API_LOCATION }}
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}
deployment_environment: "staging"
# Step 6: Post Deployment Feedback (Optional)
- name: Post Deployment URL as PR Comment
if: success()
uses: actions/github-script@v6
with:
script: |
const url = '${{ steps.deploy.outputs.preview_url }}';
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `✅ **Pre-production Deployment Successful** 🚀\n\nYou can view the changes here: ${url}`
});