Skip to content

Commit

Permalink
write permision
Browse files Browse the repository at this point in the history
  • Loading branch information
kanthesha committed Apr 12, 2024
1 parent bb338cc commit 0b8a586
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:

module-lint:
name: Module Lint
permissions:
contents: write
uses: ./.github/workflows/module-lint.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand Down
39 changes: 34 additions & 5 deletions .github/workflows/module-lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
name: Module Lint

inputs:
icon-url:
description: 'Url to the avatar used for the bot in Slack'
required: false
default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png'
username:
description: 'The name of the bot as it appears on Slack'
required: false
default: 'MetaMask bot'
subteam:
description: 'Use this if you want to ping a subteam of individuals on Slack using @'
required: false
channel:
description: 'The Slack channel to post in'
required: false
default: 'temp-test-module-lint'

on:
workflow_call:
secrets:
Expand Down Expand Up @@ -53,16 +70,28 @@ jobs:
name: Slack Post
runs-on: ubuntu-latest
steps:
- name: Post module lint report to slack
- id: final-text
shell: bash
if: secrets.SLACK_WEBHOOK_URL != ''
run: |
DEFAULT_TEXT="<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/|→ Click here to review>"
SUBTEAM_TEXT="${{ secrets.subteam }}"
FINAL_TEXT="$DEFAULT_TEXT"
if [[ ! "$SUBTEAM_TEXT" == "" ]]; then
FINAL_TEXT="<!subteam^$SUBTEAM_TEXT> $DEFAULT_TEXT"
fi
echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT"
- name: Post module lint report to a slack
id: slack
if: secrets.SLACK_WEBHOOK_URL != ''
uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844
with:
payload: |
{
"text": "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/|→ Click here to review>",
"icon_url": "https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png",
"username": "MetaMask bot",
"channel": "#temp-test-module-lint"
"text": "${{ steps.final-text.outputs.FINAL_TEXT }}",
"icon_url": "${{ inputs.icon-url }}",
"username": "${{ inputs.username }}",
"channel": "#${{ inputs.channel }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand Down

0 comments on commit 0b8a586

Please sign in to comment.