ci: actions

This commit is contained in:
xuwu 2021-03-22 21:42:21 +08:00
parent 1df8461fe3
commit 27fc8e2d27
3 changed files with 27 additions and 26 deletions

15
.github/workflows/issue.yml vendored Normal file
View File

@ -0,0 +1,15 @@
on:
issues:
types: [opened, edited]
jobs:
issue:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
ISSUEHOST: ${{ secrets.ISSUE }}
run: node ./script/issue.js

26
1.js
View File

@ -1,26 +0,0 @@
const dedup = (data, getKey = () => {} ) => {
// todo
}
let data = [
{ id: 1, v: 1 },
{ id: 2, v: 2 },
{ id: 1, v: 2 },
];
// 以 id 作为排重 key执行函数得到结果
// data = [
// { id: 1, v: 1 },
// { id: 2, v: 2 },
// ];
let data1 = [
{ id: 1, v: 1, id1: 1 },
{ id: 2, v: 2, id1: 2 },
{ id: 1, v: 2, id1: 1 },
]
// 以 id 和 id1 作为排重 key执行函数得到结果
// data1 = [
// { id: 1, v: 1, id1: 1 },
// { id: 2, v: 2, id1: 2 },
// ];

12
script/issue.js Normal file
View File

@ -0,0 +1,12 @@
const { event: { issue, action } } = JSON.parse(process.env.GITHUB_CONTEXT)
const { author_association, body, title, number } = issue
console.log(process.env.ISSUEHOST)
if (author_association === 'OWNER') {
if (action === 'edited') {
console.log(body, title, number, '----edited')
} else if (action === 'opened') {
console.log(body, title, number, '----opened')
}
}