Skip to content

Commit ee22d0d

Browse files
committed
update action
1 parent 6917ba6 commit ee22d0d

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Preproduction Deployment
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches: [ "main" ] # Adjust if your default branch is different
7+
8+
env:
9+
APP_LOCATION: "/" # Location of your client code
10+
API_LOCATION: "api" # Location of your API source code (optional)
11+
APP_ARTIFACT_LOCATION: "build" # Location where the build artifacts are generated
12+
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_PREPROD_API_TOKEN }} # Preprod SWA deployment token
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write # Needed for posting comments on PRs
17+
18+
jobs:
19+
build_and_deploy:
20+
runs-on: ubuntu-latest
21+
name: Build and Deploy to Preprod SWA
22+
steps:
23+
# Step 1: Checkout the repository
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
28+
# Step 2: Set up Node.js (Adjust version as needed)
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: '18.18'
33+
34+
- name: Install pnpm
35+
run: npm install -g pnpm
36+
37+
# Step 3: Install Dependencies
38+
- name: Install Dependencies
39+
run: |
40+
cd docs
41+
pnpm i --frozen-lockfile
42+
pnpm run build
43+
44+
# Step 4: Deploy to Azure Static Web Apps (Preprod)
45+
- name: Deploy to Azure Static Web Apps (Preprod)
46+
id: deploy
47+
uses: Azure/static-web-apps-deploy@v1
48+
with:
49+
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }}
50+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
51+
action: "upload"
52+
###### Repository/Build Configurations - Adjust these values as needed ######
53+
app_location: ${{ env.APP_LOCATION }}
54+
api_location: ${{ env.API_LOCATION }}
55+
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}
56+
###### End of Repository/Build Configurations ######
57+
58+
# Step 5: Post Deployment Feedback (Optional)
59+
- name: Post Deployment URL as PR Comment
60+
if: success()
61+
uses: actions/github-script@v6
62+
with:
63+
script: |
64+
const url = '${{ steps.deploy.outputs.preview_url }}';
65+
github.issues.createComment({
66+
issue_number: context.issue.number,
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
body: `✅ **Pre-production Deployment Successful** 🚀\n\nYou can view the changes here: ${url}`
70+
});

0 commit comments

Comments
 (0)