Giter Club home page Giter Club logo

actions-mention-to-slack's Introduction

Convert Github mention to Slack mention

This action sends mention to your slack account when you have been mentioned at github.

Feature

  • Send mention to slack if you have been mentioned
    • issue
    • pull request
  • Send notification to slack if you have been requested to review.
  • Send notification to slack if your pull request have been approved.

Inputs

Name Required Default Description
configuration-path Yes .github/mention-to-slack.yml Path to config-yaml-file to convert Github username to Slack member ID. You can use local file path or URL like https://github.com/path/to/yaml_raw_file
slack-webhook-url Yes Null Slack Incomming Webhook URL to notify.
repo-token Yes Null Github access token to fetch .github/mention-to-slack.yml file.
bot-name No Github Mention To Slack Display name for this bot on Slack.
icon-url No Null Display icon url for this bot on Slack.
run-id No Null Used for the link in the error message when an error occurs.

Example usage

.github/workflows/mention-to-slack.yml

on:
  issues:
    types: [opened, edited]
  issue_comment:
    types: [created, edited]
  pull_request:
    types: [opened, edited, review_requested]
  pull_request_review:
    types: [submitted]
  pull_request_review_comment:
    types: [created, edited]

jobs:
  mention-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: Run
        uses: abeyuya/actions-mention-to-slack@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
          icon-url: https://img.icons8.com/color/256/000000/github-2.png
          bot-name: "Send Mention from abeyuya/actions-mention-to-slack"
          run-id: ${{ github.run_id }}

.github/mention-to-slack.yml

# For Github User
# github_username: "slack_member_id"

github_username_A: "slack_member_id_A"
github_username_B: "slack_member_id_B"
github_username_C: "slack_member_id_C"
abeyuya: "XXXXXXXXX"

# For Github Team
# github_teamname: "slack_member_id"

github_teamname_A: "slack_member_id_D"

actions-mention-to-slack's People

Contributors

abeyuya avatar dependabot[bot] avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

actions-mention-to-slack's Issues

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.


  • Check this box to trigger a request for Renovate to run again on this repository

Creation of pull request review comments are triggered twice

Thank you for making a good application.

August 3rd library update includes a fix for groups. As a result it now triggers twice on pull request review comment creation.

When I changed the trigger for pull_request_review_comment to just edited it worked as before, so I'll leave the information here.

on:
  issues:
    types: [opened, edited]
  issue_comment:
    types: [created, edited]
  pull_request:
    types: [opened, edited, review_requested]
  pull_request_review:
    types: [submitted]
  pull_request_review_comment:
    types: [edited]

Broken

hi! the last vesion is not working... 🤔

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Mention to slack error in itms-legacy-import-utility

se the error below
Error: Request failed with status code 504
at createError (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.6/dist/index.js:736:15)
at settle (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.6/dist/index.js:12997:12)
at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.6/dist/index.js:13765:11)
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

Not Found

@abeyuya
こちらのアクションを利用させていただきたいのですが、エラーになってしまいます。
アドバイスいただけますと幸いです。

HttpError: Not Found
    at /home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/node_modules/@octokit/request/dist-node/index.js:86:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.loadFromGithubPath (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/modules/mappingConfig.ts:43:22)
    at main (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/main.ts:255:21)

Exception while using this actions script

HttpError: Not Found
    at /home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/node_modules/@octokit/request/dist-node/index.js:86:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.loadFromGithubPath (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/modules/mappingConfig.ts:43:22)
    at main (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/main.ts:255:21)

Not Found

%60%60%60%0AHttpError:%20Not%20Found%0A%20%20%20%20at%20/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/node_modules/@octokit/request/dist-node/index.js:86:1%0A%20%20%20%20at%20processTicksAndRejections%20(node:internal/process/task_queues:96:5)%0A%20%20%20%20at%20Object.loadFromGithubPath%20(/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/modules/mappingConfig.ts:43:22)%0A%20%20%20%20at%20main%20(/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2/src/main.ts:255:21)%0A%60%60%60

通知項目について

現在、issueやpull-requestなどに通知が発生すると思います。

今後、レビュー後のApprovedなどを通知させる予定はありますか??
回答いただけると嬉しいです!

メンションが存在しないコメントの場合に、エラーとなります

on: pull_request_review

TypeError: Cannot read property 'match' of null
    at Object.module.exports.559.exports.pickupUsername (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:12814:23)
    at Object.module.exports.131.exports.execNormalMention (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:2905:38)
    at Object.module.exports.131.exports.main (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:2952:23)
    at Object.325 (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:6470:8)
    at __webpack_require__ (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:22:30)
    at startup (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:37:19)
    at /home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:41:18
    at Object.<anonymous> (/home/runner/work/_actions/abeyuya/actions-mention-to-slack/v2.3/dist/index.js:44:10)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)

What is needed to mention works on Slack?

Hi, I'm trying to setup slack mention action on github but I can't receive the messages in channel.
What my webhook need to do to action mention in a channel?
From the Workflow builder I can create a webhook workflow and choose the channel but I need to create a message text too and I don't know if I need to put a variable or not. Should I create an app intead?

Can you guide me ou show me an example?

エラー発生

普段から、こちらのactionにお世話になっております。

問題なく使用できていたのですが、エラーが発生し、動かなくなってしまったようです。

ご確認いただけますでしょうか?

image

外部リポジトリからfetchしてきたyamlをconfiguration-pathに指定できない

いつもこちらのアクションを利用させてもらっています。ありがとうございます

organizationで利用する際、個人アカウントに依存しないようにしたく、GitHub Apps経由でprivate repositoryに保存された mention-to-slack.yml を読み込むようにして複数のリポジトリで mention-to-slack.yml を共有できるようにしたいと考えています

現在リポジトリが4つあり、

  1. SlackにリメンションしたいPrivateリポジトリ (複数)
  2. GitHub Appsを呼び出すためのPublicリポジトリ
  3. mention-to-slack.ymlが保存されたPrivateリポジトリ
  4. Slackに通知するためのアクションが保存されたPublicリポジトリ(当リポジトリのForkです)

1 の hook で workflow を起動し、2 を呼び出すことで、3に保存されたmention-to-slack.yml をcheckoutによりコピーしてきます。完了した後、4 を起動しSlackに通知するような仕組みです

GitHub Appsを経由する理由としては、権限問題を回避してPrivateリポジトリの情報を取得するためです
https://caddi.tech/archives/3737 (こちらのページを参考にしています)

当リポジトリのアクションでは

uses: abeyuya/actions-mention-to-slack@v2
with:
    configuration-path: ***mention-to-slack.yml

のようにすると、メンション先が記述されたyamlファイルを指定できると理解しています

on:
  issues:
    types: [opened]
  issue_comment:
    types: [created]
  pull_request:
    types: [opened, review_requested]
  pull_request_review:
    types: [submitted]
  pull_request_review_comment:
    types: [created]

jobs:
  mention-to-slack:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:
      # リポジトリのチェックアウト
      - uses: actions/checkout@v3
      # Github appsを使用して caddijp/common-github-actions private リポジトリを .github/actions/common にチェックアウト
      - uses: org-repo/checkout-private-action@main
        with:
          app_id: ${{ secrets.CHECKOUT_PRIVATE_ACTION_APPS_ID }}
          secret_key: ${{ secrets.CHECKOUT_PRIVATE_ACTION_APPS_SECRET }}
          org: "org-repo"
          repo: "slack-notification"
          ref: "dev"
          dist: "./.github/actions/common"
      - name: Run
        uses: k1z3/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_FOR_MENTION_DEV }}
          icon-url: https://img.icons8.com/color/256/000000/github-2.png
          bot-name: "Mention bot"
          run-id: ${{ github.run_id }}
          configuration-path: .github/actions/common/.github/actions/slack-to-mention/mention-to-slack.yml

アクション自体は最後まで正常に終了していることになっています


しかし、checkoutによって持ってきたファイルの場合は、以下のようなエラーがSlackに投稿されます (k1z3/actions-mention-to-slack は4のことで、当リポジトリのForkです)
❗ An internal error occurred in mention-to-slack action)
(but action didn't fail as this action is not critical).
To solve the problem, please open an issue

HttpError: Not Found
    at /home/runner/work/_actions/k1z3/actions-mention-to-slack/0.1.3/node_modules/@octokit/request/dist-node/index.js:86:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.loadFromGithubPath (/home/runner/work/_actions/k1z3/actions-mention-to-slack/0.1.3/src/modules/mappingConfig.ts:43:22)
    at main (/home/runner/work/_actions/k1z3/actions-mention-to-slack/0.1.3/src/main.ts:246:21)

mention-to-slack.ymlファイルについては、元々 1 のリポジトリに保存されている場合は、configuration-path を指定しても問題なく読み込めます

しかし、fetchしたyamlを直接指定したり cat して 1 のリポジトリのファイルに追記するような操作をすると、読み込めなくなってしまいます

ls 等で確認はしましたが、コピー自体は行われておりました

ちなみに存在しないパスを指定したとしても、このようなエラーになりました


もう少し単純なものにして検証も行いたいのですが、取り急ぎissueを立てさせていただきました

GH-Actions の知見が薄く申し訳ないですが、もし解決できる方法がありましたら教えていただけると嬉しいです

また、目的が達成できれば良いとも考えていますので、これ以外に良い方法を提案していただいても嬉しいです

よろしくお願いします

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.