-
Notifications
You must be signed in to change notification settings - Fork 214
93 lines (84 loc) · 2.86 KB
/
Copy pathpublish-site-azure.yml
File metadata and controls
93 lines (84 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Publish documentation (Azure)
#
# This workflow publishes the documentation to Azure static web apps
#
on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- "**"
permissions:
contents: read
pull-requests: write
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
steps:
## --- SETUP --- ##
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Enable Corepack
run: corepack enable
- name: Clean up comments from previous Azure deploys
if: github.event_name == 'pull_request'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr=${{ github.event.pull_request.number }}
comments=$(gh api repos/${{ github.repository }}/issues/$pr/comments)
echo "$comments" | jq -c '.[]' | while read -r comment; do
body=$(echo "$comment" | jq -r '.body')
id=$(echo "$comment" | jq -r '.id')
if [[ "$body" == Azure\ Static\ Web\ Apps:* ]]; then
echo "Deleting comment $id"
gh api repos/${{ github.repository }}/issues/comments/$id -X DELETE
fi
done
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
## --- INSTALL --- ##
# note: if cache-hit isn't needed b/c yarn will leverage the cache if it exists
- name: Install dependencies
shell: bash
run: yarn install --immutable
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_CLIFF_0173AA90F }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"
api_location: ""
output_location: "dist"
app_build_command: "yarn build:docs"
timeout-minutes: 10
close_pull_request_job:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
name: Clean up PR environment
steps:
- name: Remove PR environment
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_CLIFF_0173AA90F }}
action: "close"