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 axios = require("axios");
const { event: { issue, action } } = JSON.parse(process.env.GITHUB_CONTEXT) const {
const { author_association, body, title, number } = issue event: { issue, action },
const host = process.env.ISSUEHOST } = JSON.parse(process.env.GITHUB_CONTEXT);
const { author_association, body, title, number } = issue;
const host = process.env.ISSUEHOST;
if (author_association === 'OWNER') { if (author_association === "OWNER") {
if (action === 'edited') { if (action === "edited") {
axios.put(host, { axios.put(host, {
name: title, name: title,
issueId: number, issueId: number,
content: body content: body,
}) });
} else if (action === 'opened') { } else if (action === "opened") {
axios.post(host, { axios.post(host, {
name: title, name: title,
issueId: number, issueId: number,
content: body content: body,
}) });
} }
} }