Repository navigation
77 lines (68 loc) · 2.63 KB
/
Copy pathvalidate_issue.yml
File metadata and controls
77 lines (68 loc) · 2.63 KB
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
name: Validate Issue
on:
issues:
types: [opened, edited]
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
if: |
contains(join(github.event.issue.labels.*.name, ','), 'channels:') ||
contains(join(github.event.issue.labels.*.name, ','), 'feeds:') ||
contains(join(github.event.issue.labels.*.name, ','), 'logos:') ||
contains(join(github.event.issue.labels.*.name, ','), 'cities:') ||
contains(join(github.event.issue.labels.*.name, ','), 'blocklist:')
steps:
- name: Checkout repository code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
if: ${{ !env.ACT }}
id: create-app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run issue:validate
id: validator
env:
RAW_BODY: ${{ github.event.issue.body }}
LABEL_STRING: ${{ join(github.event.issue.labels.*.name, ',') }}
run: |
npm run issue:validate -- \
--body "$RAW_BODY" \
--labels "$LABEL_STRING"
- name: Handle valid request
if: success()
env:
GH_TOKEN: ${{ steps.create-app-token.outputs.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
if [ "${{ env.ACT }}" = "true" ]; then
echo "[MOCK] Add label: check:passed"
echo "[MOCK] Remove label if exists: check:failed"
else
gh issue edit $ISSUE_NUMBER --add-label "check:passed" --remove-label "check:failed"
fi
- name: Handle invalid request
if: failure() && steps.validator.outcome == 'failure'
env:
GH_TOKEN: ${{ steps.create-app-token.outputs.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
COMMENT_MSG=$(cat temp/logs/errors.txt)
if [ "${{ env.ACT }}" = "true" ]; then
echo "[MOCK] Post comment:"
echo "$COMMENT_MSG"
echo "[MOCK] Add label: check:failed"
echo "[MOCK] Remove label if exists: check:passed"
else
gh issue comment $ISSUE_NUMBER --body "$COMMENT_MSG"
gh issue edit $ISSUE_NUMBER --add-label "check:failed" --remove-label "check:passed"
fi