-
Notifications
You must be signed in to change notification settings - Fork 140
51 lines (43 loc) · 1.58 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
40
41
42
43
44
45
46
47
48
49
50
51
# 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]
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
ValidateHIP:
runs-on: improvement-proposals-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Check out repository code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
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