Skip to content

Commit

Permalink
feat: create new issue that includes table with all new endorsements (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m authored Aug 3, 2023
1 parent 9d52fde commit 1825459
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/subscribe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

0 comments on commit 1825459

Please sign in to comment.