-
Notifications
You must be signed in to change notification settings - Fork 140
39 lines (34 loc) · 1.24 KB
/
validateHeaders.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
# This is a github actions workflow that retrieves the modified hips and runs a validator script against them written in Node.
name: Validate HIP
on: [pull_request]
jobs:
ValidateHIP:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "12.x"
- name: Install jq
run: sudo apt-get install jq
- name: Validate HIPs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
REPO=${{ github.repository }}
PR_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/files")
MD_FILES=$(echo "$PR_DATA" | jq -r '.[] | select(.filename | test(".md$")) | .filename')
for FILE in $MD_FILES; do
FULL_PATH="${{ github.workspace }}/$FILE"
if [[ -f "$FULL_PATH" ]]; then
node "${{ github.workspace }}/scripts/validateHIP.js" "$FULL_PATH"
else
echo "No file found for $FILE"
exit 1
fi
done