-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (66 loc) · 2.44 KB
/
build.yml
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
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
workflow_dispatch:
jobs:
build_and_deploy_job:
name: Build and Deploy Job
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Create tag
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const { default: createGitTag } = await import('${{ github.workspace }}/scripts/createGitTag.mjs');
await createGitTag(github, context);
- name: Fetch tag
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: git fetch --tags
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./node_modules
key: app-node-modules-${{ hashFiles('./yarn.lock') }}
restore-keys: |
app-node-modules-
- name: Print config
run: yarn cfg
- name: Build And Deploy
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed')
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ github.event_name == 'workflow_dispatch' && '' || secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"
api_location: ""
output_location: "build"
env:
SKIP_DEPLOY_ON_MISSING_SECRETS: ${{ github.event_name == 'workflow_dispatch' }}
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
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: "close"
app_location: "/"
api_location: ""
output_location: "build"