-
Notifications
You must be signed in to change notification settings - Fork 145
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@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
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