diff --git a/.github/workflows/discord.yml b/.github/workflows/discord.yml index c60123c..a0d90e1 100644 --- a/.github/workflows/discord.yml +++ b/.github/workflows/discord.yml @@ -5,7 +5,7 @@ on: branches: - master pull_request: - types: [closed] + types: [closed, opened] branches: - master issues: @@ -14,16 +14,23 @@ on: jobs: notify: runs-on: ubuntu-latest - # For PRs, only run if it was actually merged (not just closed) if: | github.event_name == 'push' || github.event_name == 'issues' || - (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + (github.event_name == 'pull_request' && github.event.pull_request.merged == true) || + (github.event_name == 'pull_request' && github.event.action == 'opened') steps: - name: Send to Discord run: | + if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.action }}" == "opened" ]; then + MESSAGE="PR Opened\nPR: ${{ github.event.pull_request.html_url }}\nTitle: ${{ github.event.pull_request.title }}\nRaised by: ${{ github.event.pull_request.user.login }}" + elif [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.action }}" == "closed" ]; then + MESSAGE="PR Merged\nPR: ${{ github.event.pull_request.html_url }}\nTitle: ${{ github.event.pull_request.title }}\nRaised by: ${{ github.event.pull_request.user.login }}\nMerged by: ${{ github.event.pull_request.merged_by.login }}" + elif [ "${{ github.event_name }}" == "issues" ]; then + MESSAGE="New Issue\nIssue: ${{ github.event.issue.html_url }}\nTitle: ${{ github.event.issue.title }}\nRaised by: ${{ github.actor }}" + else + MESSAGE="Push to master\nPushed by: ${{ github.actor }}\nAuthor: ${{ github.event.head_commit.author.name }}\nCommit: ${{ github.event.head_commit.message }}" + fi curl -H "Content-Type: application/json" \ - -d "{ - \"content\": \"Repo update in ${{ github.repository }}\nEvent: ${{ github.event_name }}\nUser: ${{ github.actor }}\nBranch: ${{ github.ref_name }}\" - }" \ + -d "{\"content\": \"<@&${{ secrets.DISCORD_ATOMIC_ROLE_ID }}> $MESSAGE\"}" \ ${{ secrets.DISCORD_WEBHOOK }}