-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create new issue that includes table with all new endorsements (#…
…23)
- Loading branch information
Showing
1 changed file
with
34 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,15 +13,39 @@ jobs: | |
with: | ||
app_id: ${{ vars.ALL_CONTRIBUTORS_IMPORT_APP_ID }} | ||
private_key: ${{ secrets.ALL_CONTRIBUTORS_IMPORT_APP_PRIVATE_KEY }} | ||
- uses: octokit/[email protected] | ||
- uses: actions/github-script@v6 | ||
env: | ||
START_SEQ: ${{ github.event.client_payload.startSeq }} | ||
END_SEQ: ${{ github.event.client_payload.endSeq }} | ||
with: | ||
route: "POST /repos/{repository}/issues" | ||
repository: ${{ github.repository }} | ||
title: "🤖📯 New update available" | ||
body: | | ||
| | ||
Start seq: ${{ github.event.client_payload.startSeq }} | ||
End seq: ${{ github.event.client_payload.endSeq }} | ||
github-token: ${{ steps.app-token.outputs.token }} | ||
script: | | ||
// download the latest version of endorsements.csv | ||
const response = await fetch( | ||
"https://raw.githubusercontent.com/gr2m/all-contributors-import/main/data/endorsements.csv" | ||
); | ||
const text = await response.text(); | ||
env: | ||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
// find all new endorsements | ||
const [firstLine, ...lines] = text.split("\n"); | ||
const newLines = lines.filter((line) => { | ||
const [seq] = line.split(","); | ||
return Number(seq) >= process.env.START_SEQ; | ||
}); | ||
// create a markdown table | ||
const headers = firstLine.split(","); | ||
const table = `|${headers.join("|")}| | ||
|${headers.map(() => "-").join("|")}| | ||
${newLines.map((line) => `|${line.split(",").join("|")}|`).join("\n")} | ||
`; | ||
// create a new issue | ||
github.request("POST /repos/{repository}/issues", { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: `🤖📯 ${ | ||
process.env.END_SEQ - process.env.START_SEQ | ||
} new endorsements have been added`, | ||
body: table, | ||
}); |