Skip to content

M #-: Minor OneForm adjustments (#3973) #278

M #-: Minor OneForm adjustments (#3973)

M #-: Minor OneForm adjustments (#3973) #278

name: Slack Push Notifier
on:
push:
branches: [master]
pull_request:
types: [closed]
branches: [master]
workflow_dispatch:
jobs:
notify_slack_push:
name: Notify Slack on pushes
runs-on: ubuntu-latest
steps:
- name: Set commit message for push
if: github.event_name == 'push'
run: |
HEADLINE=$(echo "${{ github.event.head_commit.message }}" | head -n1)
HEADLINE=$(echo "$HEADLINE" | tr -cd '[:alnum:]_. -')
echo "COMMIT_ONELINER=$HEADLINE" >> $GITHUB_ENV
echo "COMMIT_URL=${{ github.event.head_commit.url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=direct push" >> $GITHUB_ENV
- name: Set commit message for PR
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
run: |
HEADLINE="${{ github.event.pull_request.merge_commit_title }}"
HEADLINE=$(echo "$HEADLINE" | tr -cd '[:alnum:]_. -')
echo "COMMIT_ONELINER=$HEADLINE" >> $GITHUB_ENV
echo "COMMIT_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=pull request merged" >> $GITHUB_ENV
- name: Send notification to slack
if: ${{ github.repository == 'OpenNebula/one-ee' && env.COMMIT_ONELINER != '' }}
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "New ${{env.EVENT_TYPE}}"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "> --> *New commit:* <${{ env.COMMIT_URL }}|${{ env.COMMIT_ONELINER }}>"