Update open-source-places.astro #1743
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Schedule (SGID Index Validation) | |
on: | |
schedule: | |
- cron: '0 0 * * 1-5' | |
workflow_dispatch: | |
issue_comment: | |
types: [created, edited] | |
permissions: | |
issues: write | |
jobs: | |
validate: | |
name: Validate SGID Index | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./scripts | |
env: | |
GOOGLE_PRIVATE_KEY: ${{ secrets.SA }} | |
RESULTS_COMMENT_TITLE: SGID Index Validation | |
steps: | |
- name: ✅ Check comment | |
if: github.event_name == 'issue_comment' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const commentBody = context.payload.comment.body; | |
if (commentBody.startsWith('/validate-sgid-index')) { | |
github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: context.payload.comment.id, | |
content: '+1' | |
}); | |
console.log('Validating SGID Index'); | |
github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number | |
}).then(({data}) => { | |
const comment = data.find(comment => comment.user.login === 'github-actions[bot]' && comment.body.includes(process.env.RESULTS_COMMENT_TITLE)); | |
if (comment) { | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: comment.id, | |
body: `### ${process.env.RESULTS_COMMENT_TITLE}\n\n♻️Processing...♻️` | |
}); | |
} | |
}); | |
} else { | |
console.log('Skipping SGID Index validation'); | |
process.exit(78); | |
} | |
- name: ⬇️ Check out code | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
sparse-checkout: | | |
scripts | |
src/data | |
- 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: ./scripts | |
- name: 📝 Create or find existing issue | |
id: create-or-find-issue | |
uses: actions/github-script@v7 | |
with: | |
retries: 3 | |
result-encoding: string | |
script: | | |
const label = 'sgid index validation'; | |
const title = 'SGID Index Validation Issues'; | |
console.log('searching for existing issue'); | |
const query = ` | |
{ | |
repository(owner: "${context.repo.owner}", name: "${context.repo.repo}") { | |
issues( | |
first: 100 | |
labels: ["${label}"] | |
states: OPEN | |
filterBy: {createdBy: "github-actions[bot]"} | |
) { | |
nodes { | |
number | |
} | |
} | |
} | |
}`; | |
const result = await github.graphql(query); | |
if (result.repository.issues.nodes.length > 0) { | |
const issueNumber = result.repository.issues.nodes[0].number; | |
console.log(`Issue already exists: ${issueNumber}`); | |
return issueNumber; | |
} else if (${{ steps.validate.outputs.exitCode }} !== 0) { | |
// create new issue if there are validation errors | |
console.log('Creating new issue'); | |
const body = require('fs').readFileSync(process.env.GITHUB_WORKSPACE + '/.github/SGID_INDEX_ISSUE_TEMPLATE.md', 'utf8'); | |
const issue = await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title, | |
body, | |
labels: [label] | |
}); | |
return issue.data.number; | |
} else { | |
return ''; | |
} | |
- name: Find Comment | |
uses: peter-evans/find-comment@v3 | |
if: steps.create-or-find-issue.outputs.result | |
id: find-comment | |
with: | |
issue-number: ${{ steps.create-or-find-issue.outputs.result }} | |
comment-author: github-actions[bot] | |
body-includes: ${{ env.RESULTS_COMMENT_TITLE}} | |
- name: 🕰 Get Timestamp | |
id: timestamp | |
if: steps.create-or-find-issue.outputs.result | |
run: echo "result=$(TZ=America/Denver date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT | |
- name: ✍️ Updating issue comment with results | |
if: steps.create-or-find-issue.outputs.result | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ steps.create-or-find-issue.outputs.result }} | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
### ${{ env.RESULTS_COMMENT_TITLE }} | |
*${{ steps.timestamp.outputs.result }}* | |
#### Script Output | |
``` | |
${{ steps.validate.outputs.stdout }} | |
``` | |
#### Validation 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 | |
run: gh issue close --comment "All validations have passed successfully" "${{ steps.create-or-find-issue.outputs.result }}" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |