generated from saic-oss/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Taskfile.yml
126 lines (114 loc) · 3.92 KB
/
Taskfile.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# https://taskfile.dev
version: "3"
tasks:
validate:
desc: Validate the pre-commit hooks
cmds:
- pre-commit install
- pre-commit run -a
test:
desc: Run automated tests
cmds:
- task: build
secure:
desc: Run automated security checks
cmds:
- echo "TODO: Figure out what the right security scans to run are (if any)"
deliver:
desc: Create and push index.yaml to gh-pages branch
vars:
# Username of GitHub user that will perform the push
GIT_USER: '{{ coalesce .GIT_USER "<no value>" }}'
# API Token for $GIT_USER
GIT_PASS: '{{ coalesce .GIT_PASS "<no value>" }}'
# Branch that the website will be deployed to. Should be 'gh-pages' in most cases
DEPLOYMENT_BRANCH: '{{ coalesce .DEPLOYMENT_BRANCH "gh-pages" }}'
# Branch that contains the latest docs changes that will be deployed. Should be 'main' in most cases.
CURRENT_BRANCH: '{{ coalesce .CURRENT_BRANCH "<no value>" }}'
# User Name to use in the commit signature. Can be different from $GIT_USER
GIT_CONFIG_USR: '{{ coalesce .GIT_CONFIG_USR "<no value>" }}'
# Email address to use in the commit signature. Can be different from $GIT_USER's email address
GIT_CONFIG_EMAIL: '{{ coalesce .GIT_CONFIG_EMAIL "<no value>" }}'
preconditions:
- sh: test "{{.GIT_USER}}" != "<no value>"
msg: "GIT_USER not set"
- sh: test "{{.GIT_PASS}}" != "<no value>"
msg: "GIT_PASS not set"
- sh: test "{{.DEPLOYMENT_BRANCH}}" != "<no value>"
msg: "DEPLOYMENT_BRANCH not set"
- sh: test "{{.CURRENT_BRANCH}}" != "<no value>"
msg: "CURRENT_BRANCH not set"
- sh: test "{{.GIT_CONFIG_USR}}" != "<no value>"
msg: "GIT_CONFIG_USR not set"
- sh: test "{{.GIT_CONFIG_EMAIL}}" != "<no value>"
msg: "GIT_CONFIG_EMAIL not set"
cmds:
- task: git:config
- task: npm:install
- task: npm:deploy
deploy:
desc: Deploy project
cmds:
- echo "N/A. This project uses the 'deliver' task to release to GitHub Pages
start:
desc: Run the Docusaurus site locally
dir: webapp
cmds:
- npm run start
build:
desc: Build the Docusaurus static content
dir: webapp
cmds:
- task: npm:install
- task: npm:build
npm:install:
dir: webapp
cmds:
- |
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm:build:
dir: webapp
cmds:
- npm run build
npm:deploy:
dir: webapp
vars:
GIT_USER: '{{ coalesce .GIT_USER "<no value>" }}'
GIT_PASS: '{{ coalesce .GIT_PASS "<no value>" }}'
DEPLOYMENT_BRANCH: '{{ coalesce .DEPLOYMENT_BRANCH "<no value>" }}'
CURRENT_BRANCH: '{{ coalesce .CURRENT_BRANCH "<no value>" }}'
preconditions:
- sh: test "{{.GIT_USER}}" != "<no value>"
msg: "GIT_USER not set"
- sh: test "{{.GIT_PASS}}" != "<no value>"
msg: "GIT_PASS not set"
- sh: test "{{.DEPLOYMENT_BRANCH}}" != "<no value>"
msg: "DEPLOYMENT_BRANCH not set"
- sh: test "{{.CURRENT_BRANCH}}" != "<no value>"
msg: "CURRENT_BRANCH not set"
cmds:
- npx docusaurus deploy
git:config:
vars:
GIT_CONFIG_USR: '{{ coalesce .GIT_CONFIG_USR "<no value>" }}'
GIT_CONFIG_EMAIL: '{{ coalesce .GIT_CONFIG_EMAIL "<no value>" }}'
preconditions:
- sh: test "{{.GIT_CONFIG_USR}}" != "<no value>"
msg: "GIT_CONFIG_USR not set"
- sh: test "{{.GIT_CONFIG_EMAIL}}" != "<no value>"
msg: "GIT_CONFIG_EMAIL not set"
cmds:
- |
if [ "$CI" == "true" ]; then
git config --global user.name "{{.GIT_CONFIG_USR}}"
git config --global user.email "{{.GIT_CONFIG_EMAIL}}"
else
git config user.name "{{.GIT_CONFIG_USR}}"
git config user.email "{{.GIT_CONFIG_EMAIL}}"
fi