diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..55a56fd --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Discord Notification + +on: + push: + branches: + - main + +jobs: + discord: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get commit details + id: get_commit + run: | + echo "::set-output name=message::$(git log -1 --pretty=format:"%s")" + echo "::set-output name=committer::$(git log -1 --pretty=format:"%cn")" + echo "::set-output name=url::https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" + + - name: Send Discord notification + uses: appleboy/discord-action@master + with: + webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} + webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} + color: '16711680' + username: 'GitHub Actions Bot' + message: 'New commit on the main branch: "${{ steps.get_commit.outputs.message }}" by ${{ steps.get_commit.outputs.committer }}. [Check it out](${{ steps.get_commit.outputs.url }}).'