mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make Slack notification available
for macOS / Windows as well. Docker-based GitHub Action does not work on these OSes.
This commit is contained in:
parent
aa5fbb5a76
commit
e139d27748
4 changed files with 30 additions and 71 deletions
53
.github/actions/notify-slack/action.yml
vendored
53
.github/actions/notify-slack/action.yml
vendored
|
@ -1,53 +0,0 @@
|
|||
name: notify-slack
|
||||
description: You can notify slack of GitHub Actions.
|
||||
author: k0kubun
|
||||
inputs:
|
||||
status:
|
||||
description: Success or Failure
|
||||
matrix_name:
|
||||
description: Matrix task name
|
||||
committer_name:
|
||||
description: Git committer name
|
||||
commit_message:
|
||||
description: Git commit message
|
||||
commit_timestamp:
|
||||
description: Git commit timestamp
|
||||
runs:
|
||||
using: docker
|
||||
image: 'docker://ruby:2.6-slim'
|
||||
args:
|
||||
- /usr/local/bin/ruby
|
||||
- -e
|
||||
- |-
|
||||
require 'json'
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
github_repo = ENV.fetch('GITHUB_REPOSITORY')
|
||||
github_sha = ENV.fetch('GITHUB_SHA')
|
||||
github_ref = ENV.fetch('GITHUB_REF')
|
||||
|
||||
workflow = ENV.fetch('GITHUB_WORKFLOW')
|
||||
matrix = ENV.fetch('INPUT_MATRIX_NAME')
|
||||
status = ENV.fetch('INPUT_STATUS')
|
||||
|
||||
message = ENV.fetch('INPUT_COMMIT_MESSAGE')
|
||||
timestamp = ENV.fetch('INPUT_COMMIT_TIMESTAMP')
|
||||
committer = ENV.fetch('INPUT_COMMITTER_NAME')
|
||||
|
||||
commit_url = "https://github.com/#{github_repo}/commit/#{github_sha}"
|
||||
attachment = {
|
||||
title: "#{status}: #{workflow} / #{matrix}",
|
||||
title_link: "#{commit_url}/checks",
|
||||
text: "<#{commit_url}|#{github_sha[0...10]}> of #{github_repo}@#{File.basename(github_ref)} "\
|
||||
"by #{committer} on #{timestamp}: #{message}",
|
||||
color: status == 'Success' ? 'good' : 'danger',
|
||||
}
|
||||
|
||||
resp = Net::HTTP.post(
|
||||
URI(ENV.fetch('SLACK_WEBHOOK_URL')),
|
||||
{ attachments: [attachment] }.to_json,
|
||||
{ 'Content-Type' => 'application/json' },
|
||||
)
|
||||
puts "#{resp.code} (#{resp.body}) -- #{payload.to_json}"
|
||||
resp.value
|
16
.github/workflows/macos.yml
vendored
16
.github/workflows/macos.yml
vendored
|
@ -49,13 +49,17 @@ jobs:
|
|||
MSPECOPT: "-ff" # not using `-j` because sometimes `mspec -j` silently dies
|
||||
- name: Leaked Globals
|
||||
run: make -s leaked-globals
|
||||
- uses: ./.github/actions/notify-slack
|
||||
- uses: k0kubun/action-slack@v1.0.0
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
matrix_name: ${{ matrix.test_task }}
|
||||
committer_name: ${{ github.event.head_commit.committer.name }}
|
||||
commit_message: ${{ github.event.head_commit.message }}
|
||||
commit_timestamp: ${{ github.event.head_commit.timestamp }}
|
||||
payload: |
|
||||
{
|
||||
"attachments": [{
|
||||
"title": "${{ job.status }}: ${{ github.workflow }} / ${{ matrix.test_task }}",
|
||||
"title_link": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks",
|
||||
"text": "${{ github.repository }}@${{ github.ref }}: <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\nby ${{ github.event.head_commit.committer.name }} on ${{ github.event.head_commit.timestamp }}: ${{ github.event.head_commit.message }}",
|
||||
"color": "danger"
|
||||
}]
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: failure() && github.event_name == 'push'
|
||||
|
|
16
.github/workflows/ubuntu.yml
vendored
16
.github/workflows/ubuntu.yml
vendored
|
@ -52,13 +52,17 @@ jobs:
|
|||
MSPECOPT: "-ff" # not using `-j` because sometimes `mspec -j` silently dies
|
||||
- name: Leaked Globals
|
||||
run: make -s leaked-globals
|
||||
- uses: ./.github/actions/notify-slack
|
||||
- uses: k0kubun/action-slack@v1.0.0
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
matrix_name: ${{ matrix.test_task }}
|
||||
committer_name: ${{ github.event.head_commit.committer.name }}
|
||||
commit_message: ${{ github.event.head_commit.message }}
|
||||
commit_timestamp: ${{ github.event.head_commit.timestamp }}
|
||||
payload: |
|
||||
{
|
||||
"attachments": [{
|
||||
"title": "${{ job.status }}: ${{ github.workflow }} / ${{ matrix.test_task }}",
|
||||
"title_link": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks",
|
||||
"text": "${{ github.repository }}@${{ github.ref }}: <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\nby ${{ github.event.head_commit.committer.name }} on ${{ github.event.head_commit.timestamp }}: ${{ github.event.head_commit.message }}",
|
||||
"color": "danger"
|
||||
}]
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: failure() && github.event_name == 'push'
|
||||
|
|
16
.github/workflows/windows.yml
vendored
16
.github/workflows/windows.yml
vendored
|
@ -53,13 +53,17 @@ jobs:
|
|||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs }}\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
nmake ${{ matrix.test_task }}
|
||||
- uses: ./.github/actions/notify-slack
|
||||
- uses: k0kubun/action-slack@v1.0.0
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
matrix_name: ${{ matrix.test_task }}
|
||||
committer_name: ${{ github.event.head_commit.committer.name }}
|
||||
commit_message: ${{ github.event.head_commit.message }}
|
||||
commit_timestamp: ${{ github.event.head_commit.timestamp }}
|
||||
payload: |
|
||||
{
|
||||
"attachments": [{
|
||||
"title": "${{ job.status }}: ${{ github.workflow }} / ${{ matrix.test_task }}",
|
||||
"title_link": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks",
|
||||
"text": "${{ github.repository }}@${{ github.ref }}: <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\nby ${{ github.event.head_commit.committer.name }} on ${{ github.event.head_commit.timestamp }}: ${{ github.event.head_commit.message }}",
|
||||
"color": "danger"
|
||||
}]
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: failure() && github.event_name == 'push'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue