chore: actions

This commit is contained in:
虚无 2021-03-23 10:50:25 +08:00
parent bd79888d86
commit 45b0967015
3 changed files with 62 additions and 19 deletions

17
.github/workflows/comment.yml vendored Normal file
View File

@ -0,0 +1,17 @@
on:
issue_comment:
types: [created, 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.ISSUEHOST }}
run: |
yarn
node ./script/issue.js

24
script/comment.js Normal file
View File

@ -0,0 +1,24 @@
const axios = require("axios");
const {
event: { issue, action },
} = JSON.parse(process.env.GITHUB_CONTEXT);
const { author_association, body, title, number } = issue;
const host = process.env.ISSUEHOST;
console.log(JSON.parse(process.env.GITHUB_CONTEXT););
// if (author_association === "OWNER") {
// if (action === "edited") {
// axios.put(host, {
// name: title,
// issueId: number,
// content: body,
// });
// } else if (action === "opened") {
// axios.post(host, {
// name: title,
// issueId: number,
// content: body,
// });
// }
// }

View File

@ -1,20 +1,22 @@
const axios = require('axios')
const { event: { issue, action } } = JSON.parse(process.env.GITHUB_CONTEXT)
const { author_association, body, title, number } = issue
const host = process.env.ISSUEHOST
const axios = require("axios");
const {
event: { issue, action },
} = JSON.parse(process.env.GITHUB_CONTEXT);
const { author_association, body, title, number } = issue;
const host = process.env.ISSUEHOST;
if (author_association === 'OWNER') {
if (action === 'edited') {
axios.put(host, {
name: title,
issueId: number,
content: body
})
} else if (action === 'opened') {
axios.post(host, {
name: title,
issueId: number,
content: body
})
}
}
if (author_association === "OWNER") {
if (action === "edited") {
axios.put(host, {
name: title,
issueId: number,
content: body,
});
} else if (action === "opened") {
axios.post(host, {
name: title,
issueId: number,
content: body,
});
}
}