-
Notifications
You must be signed in to change notification settings - Fork 42
125 lines (107 loc) · 3.73 KB
/
schedule.sgid-index-validation.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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Schedule (SGID Index Validation)
on:
schedule:
- cron: '0 0 * * 1-5'
workflow_dispatch:
issue_comment:
types: [created, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
issues: write
jobs:
validate:
name: Validate SGID Index
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/scripts
env:
GOOGLE_PRIVATE_KEY: ${{ secrets.SA }}
steps:
- name: ✅ Check comment
if: github.event_name == 'issue_comment'
run: |
if [[ "${{ github.event.comment.body }}" == "/validate-sgid-index" ]]; then
echo "Validating SGID Index"
else
echo "Skipping SGID Index validation"
exit 78
fi
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false
- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- name: 📦 Install script dependencies
run: npm install
- name: ✔ Running script
uses: gh640/command-result-action@v1
id: validate
with:
command: node validate-sgid-index.mjs
cwd: ./src/scripts
- name: 📝 Create issue
id: create-issue
if: steps.validate.outputs.exitCode != 0
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/SGID_INDEX_ISSUE_TEMPLATE.md
update_existing: true
- name: Find Open Issues
uses: actions/github-script@v4
id: find-issue
if: steps.validate.outputs.exitCode == 0
with:
script: |
const { data: issues } = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'sgid index validation'
});
const issueNumber = issues[0]?.number;
console.log('issueNumber: ' + issueNumber);
return issueNumber;
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Find Comment
uses: peter-evans/find-comment@v3
if: steps.create-issue.outputs.number || steps.find-issue.outputs.result
id: find-comment
with:
issue-number: ${{ steps.create-issue.outputs.number || steps.find-issue.outputs.result }}
comment-author: github-actions[bot]
body-includes: Validation Output
- name: ✍️ Updating issue comment
if: steps.create-issue.outputs.number || steps.find-issue.outputs.result
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.create-issue.outputs.number || steps.find-issue.outputs.result }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
### SGID Index Validation Output
#### Results
```
${{ steps.validate.outputs.stdout }}
```
#### Errors
${{ steps.validate.outputs.stderr }}
- name: 🚦 Check for errors
if: steps.validate.outputs.exitCode != 0
run: |
echo "::error::Validate stderr${{ steps.validate.outputs.stderr }}"
exit ${{ steps.validate.outputs.exitCode }}
- name: 🎉 Close issue
if: steps.validate.outputs.exitCode == 0 && steps.find-issue.outputs.result
run: gh issue close --comment "All validations have passed successfully" "${{ steps.find-issue.outputs.result }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}