Skip to content

Fix slackbot issues with double quotes #6

Fix slackbot issues with double quotes

Fix slackbot issues with double quotes #6

Workflow file for this run

name: slack-PR-message
on:
pull_request_target:
types:
- opened
permissions:
contents: read
pull-requests: read
jobs:
post-to-slack:
runs-on: ubuntu-20.04
steps:
- name: Check user permissions (allow only those w/ write access)
id: permission_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
user_permission=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission)
if [[ "$user_permission" != "write" && "$user_permission" != "admin" ]]; then
echo "User does not have write access. Exiting."
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Python dependency
run: pip install -r .github/requirements.txt
- name: Summarize PR body and process labels
id: summarize
env:
PR_LABELS_JSON: ${{ toJSON(github.event.pull_request.labels) }}
PR_BODY: ${{ github.event.pull_request.body }}
run: python .github/slack-bot.py
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'C08080W3W0Y'
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "New *story-ramp* PR by *${{ github.event.pull_request.user.login }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Title*: ${{ github.event.pull_request.title }}\n*PR Type*: ${{ env.PR_LABEL_STR }}\n*Other labels*: ${{ env.REG_LABEL_STR }}\n*Link*: ${{ github.event.pull_request.html_url }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*PR Summary*:\n${{ env.NEUTRAL_SUMMARY }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}