-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (121 loc) · 4.39 KB
/
node.js.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20] # Specify Node.js 20
# Output whether the build job runs based on the file changes
outputs:
should_run_build: ${{ steps.build_check.outputs.build_ran }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch the last two commits to ensure `git diff` works
- name: Check if TypeScript files were modified
id: build_check
run: |
MODIFIED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
if [[ "$MODIFIED_FILES" == *"src/**/*.ts"* ]]; then
echo "Build should run."
echo "::set-output name=build_ran::true"
else
echo "No TypeScript files were modified."
echo "::set-output name=build_ran::false"
fi
- name: Setup Node.js
if: steps.build_check.outputs.build_ran == 'true'
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
if: steps.build_check.outputs.build_ran == 'true'
run: npm install
- name: Compile TypeScript
if: steps.build_check.outputs.build_ran == 'true'
run: npx tsc
- name: Run tests
if: steps.build_check.outputs.build_ran == 'true'
run: npm test
- name: Upload artifacts
if: steps.build_check.outputs.build_ran == 'true'
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch the last two commits to ensure `git diff` works
- name: Download artifacts
if: needs.build.outputs.should_run_build == 'true'
uses: actions/download-artifact@v3
with:
name: dist
- name: Authenticate to Google Cloud for clingen-swc
if: needs.build.outputs.should_run_build == 'true'
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Setup Google Cloud SDK
if: needs.build.outputs.should_run_build == 'true'
uses: google-github-actions/setup-gcloud@v1
with:
version: 'latest'
- name: Get modified files
id: get_changed_files
run: |
MODIFIED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
echo "$MODIFIED_FILES" > modified_files.txt
- name: Execute clingen-stage BigQuery Function Scripts
run: |
echo "Executing BigQuery function scripts for clingen-stage in alphabetical order..."
MODIFIED_FILES=$(cat modified_files.txt)
for file in $(find ./scripts -type f -name '*-func.sql' | sort); do
if echo "$MODIFIED_FILES" | grep -q "$file"; then
echo "Executing $file..."
bq query --use_legacy_sql=false --project_id=$PROJECT_ID < "$file"
else
echo "Skipping $file as it was not modified."
fi
done
env:
PROJECT_ID: 'clingen-stage'
- name: Execute clingen-dev BigQuery Function Scripts
run: |
echo "Executing BigQuery function scripts for clingen-dev in alphabetical order..."
MODIFIED_FILES=$(cat modified_files.txt)
for file in $(find ./scripts -type f -name '*-func.sql' | sort); do
if echo "$MODIFIED_FILES" | grep -q "$file"; then
echo "Executing $file..."
bq query --use_legacy_sql=false --project_id=$PROJECT_ID < "$file"
else
echo "Skipping $file as it was not modified."
fi
done
env:
PROJECT_ID: 'clingen-dev'
- name: Execute clingen-dev BigQuery Procedure Scripts
run: |
echo "Executing BigQuery procedure scripts for clingen-dev in alphabetical order..."
MODIFIED_FILES=$(cat modified_files.txt)
for file in $(find ./scripts -type f -name '*-proc.sql' | sort); do
if echo "$MODIFIED_FILES" | grep -q "$file"; then
echo "Executing $file..."
bq query --use_legacy_sql=false --project_id=$PROJECT_ID < "$file"
else
echo "Skipping $file as it was not modified."
fi
done
env:
PROJECT_ID: 'clingen-dev'