-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (58 loc) · 2.27 KB
/
checklist.yaml
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
name: Add checklist
on:
issues:
types: [labeled]
jobs:
update-proceedings:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check labels
id: check_labels
uses: actions/github-script@v7
with:
script: |
const labels = context.payload.issue.labels.map(label => label.name);
const hasApproved = labels.includes('approved');
const hasChecklist = labels.includes('checklist');
return hasApproved && hasChecklist;
- name: Early exit
if: steps.check_labels.outputs.result == 'false'
run: echo "Not an approved checklist issue - exiting"
- name: Checkout
if: steps.check_labels.outputs.result == 'true'
uses: actions/checkout@v4
- name: Extract checklist data
if: steps.check_labels.outputs.result == 'true'
run: |
issue_body='${{ github.event.issue.body }}'
checklist=$(echo "$issue_body" | sed -n '/```json/,/```/p' | sed '1d;$d')
name=$(echo "$checklist" | jq -r '.name' | sed 's/ /_/g')
echo "checklist=$(echo $checklist)" >> $GITHUB_ENV
echo "name=$(echo $name)" >> $GITHUB_ENV
- name: Create file
if: steps.check_labels.outputs.result == 'true'
run: |
file_name="src/lib/data/entries/checklist_${{ env.name }}.json"
echo "file_name=$(echo $file_name)" >> $GITHUB_ENV
echo '${{ env.checklist }}' | jq . > $file_name
- name: Validate checklist
if: steps.check_labels.outputs.result == 'true'
uses: GrantBirki/json-yaml-validate@v3
with:
base_dir: src/lib/data/entries
json_schema: .github/static/checklist_schema.json
ajv_strict_mode: false
json_exclude_regex: ''
- name: Configure git
if: steps.check_labels.outputs.result == 'true'
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit files
if: steps.check_labels.outputs.result == 'true'
run: |
git add ${{ env.file_name }}
git commit -m 'Closes #${{ github.event.issue.number }}'
git push