Skip to content

Commit

Permalink
add pull_request disptch ref howijd/howijd.network#82
Browse files Browse the repository at this point in the history
  • Loading branch information
mkungla committed Sep 25, 2021
1 parent 31c0589 commit ee77d17
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/github-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ on:
types:
- created

pull_request:
types:
- opened

schedule:
- name: 'daily'
cron: '0 0 * * *' # e.g. 5min */5 * * * *
Expand Down Expand Up @@ -124,6 +128,23 @@ jobs:
core.info(zen)
core.setOutput('zen', zen)
pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
zen: ${{ steps.set-from-github-api.outputs.zen }}
steps:
- name: set from github api
id: set-from-github-api
uses: actions/github-script@v5
with:
script: |
// RANDOM SENTENCE
// const zen = await github.rest.meta.getZen()
const { data: zen } = await github.request('GET /zen')
core.info(zen)
core.setOutput('zen', zen)
issue-comment:
name: Issue comment
runs-on: ubuntu-latest
Expand Down Expand Up @@ -186,14 +207,16 @@ jobs:
- issue-comment
- discussion
- discussion-comment
- pull-request
runs-on: ubuntu-latest
if: |
!failure() && !cancelled() && (success('issue-comment') || success('issue') || success('discussion') || success('discussion-comment')) &&
!failure() && !cancelled() && (success('issue-comment') || success('issue') || success('discussion') || success('discussion-comment') || success('pull-request')) &&
(
(github.event_name == 'issue_comment' && github.event.action == 'created') ||
(github.event_name == 'issues' && github.event.action == 'opened') ||
(github.event_name == 'discussion' && github.event.action == 'created') ||
(github.event_name == 'discussion_comment' && github.event.action == 'created')
(github.event_name == 'discussion_comment' && github.event.action == 'created') ||
(github.event_name == 'pull_request' && github.event.action == 'opened')
)
outputs:
discord-enabled: ${{ steps.discord.outputs.enabled }}
Expand Down Expand Up @@ -229,6 +252,18 @@ jobs:
payload.color = `#${context.payload.issue.labels[0].color}`
}
break
case 'pull_request':
payload.link = context.payload.pull_request.html_url
payload.icon = context.payload.organization.avatar_url
payload.title = `#${context.payload.pull_request.number} ${context.payload.pull_request.title}`
payload.author_name = context.payload.sender.login
payload.author_avatar_url = context.payload.sender.avatar_url
payload.author_link = context.payload.sender.html_url
body = context.payload.pull_request.body
if (context.payload.pull_request.labels.length > 0) {
payload.color = `#${context.payload.pull_request.labels[0].color}`
}
break
case 'issue_comment':
payload.link = context.payload.comment.html_url
payload.icon = context.payload.organization.avatar_url
Expand Down
4 changes: 4 additions & 0 deletions workflow-templates/github-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ on:
types:
- created

pull_request:
types:
- opened

schedule:
- name: 'daily'
cron: '0 0 * * *' # e.g. 5min */5 * * * *
Expand Down

0 comments on commit ee77d17

Please sign in to comment.