Skip to content

Commit

Permalink
wip: workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
clockworkgr committed Jul 8, 2024
1 parent db0ace4 commit f997352
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/chain-issue-to-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: |
Automated commit: ${{github.event.issue.title}}
${{github.event.issue.body}}
title: "Automated PR ${{github.event.issue.title}}"
body: |
Closes #${{ github.event.issue.number }}
25 changes: 24 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
var fs = require('fs');

const context = JSON.parse(process.env.GITHUB_CONTEXT);
const submitter = context.actor;
const submissionDate = context.event.issue.created_at;

const template_fields = context.event.issue.body.split("### ").slice(1);
const addChainPR = (fields) => {
const chainId = fields[0].split("\n\n")[1];
const note = fields[1].split("\n\n").slice(1,-1);
const note = fields[1].split("\n\n").slice(1,-1).join("\r\n");
const threatLevel=fields[2].split("\n\n")[1][0];
const blacklist = JSON.parse(fs.readFileSync('chain-blacklist.json', 'utf8'));
const exists = blacklist.find(x => x.chainId ==chainId);
if (exists>=0) {
blacklist[exists].userNotes.push({
userName: submitter,
userNote: note,
noteDate: submissionDate
})
}else{
blacklist.push({
chainId,
submissionDate,
threatLevel,
userNotes: [{
userName: submitter,
userNote: note,
noteDate: submissionDate
}]
})
}
fs.writeFileSync("chain-blacklist.json", JSON.stringify(blacklist));
console.log( {chainId,note,threatLevel});
}
if (context.event.issue.title.startsWith("[Chain-add]: ")) {
Expand Down

0 comments on commit f997352

Please sign in to comment.