From 43d118e287102a56a0b16db5126654ae7d5dde63 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Mon, 22 Jul 2024 22:08:49 +0700 Subject: [PATCH] wf add message --- .github/workflows/build-deploy.yml | 8 ++++++++ .github/workflows/send-message.yml | 32 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/send-message.yml diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index c14dcc4..cfb6f99 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -61,6 +61,13 @@ jobs: cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + send_message: + needs: build + uses: ./.github/workflows/send-message.yml + secrets: inherit + with: + IMAGE_TAG: ${{ needs.build.outputs.IMAGE_TAG }} + cd: name: Continuous Deployment needs: build @@ -91,3 +98,4 @@ jobs: with: repository: isd-sgcu/rpkm67-devops github_token: ${{ secrets.RPKM67_DEVOPS_TOKEN }} + \ No newline at end of file diff --git a/.github/workflows/send-message.yml b/.github/workflows/send-message.yml new file mode 100644 index 0000000..ff35264 --- /dev/null +++ b/.github/workflows/send-message.yml @@ -0,0 +1,32 @@ +name: Send Messages + +on: + workflow_call: + inputs: + IMAGE_TAG: + required: true + type: string + +jobs: + send_message: + runs-on: ubuntu-latest + + steps: + - name: Send message to Discord + run: | + curl -X POST -H "Content-Type: application/json" \ + -H "Authorization: Bot ${{ secrets.RPKM67_DISCORD_API_KEY }}" \ + -d "{ + \"content\": \"A new push has been made to the **${{ github.event.pull_request.base.ref }}** branch by ${{ github.actor }}!\", + \"embeds\": [ + { + \"author\": { + \"name\": \"${{ github.actor }}\", + \"icon_url\": \"https://github.com/${{ github.actor }}.png\" + }, + \"description\": \"**Service Name:** ${{ github.repository }}\n\n**Version:**\n${{ inputs.IMAGE_TAG }}\n\n**Details:**\n${{ github.event.pull_request.title || github.event.head_commit.message }}\", + \"color\": 5814783 + } + ] + }" \ + ${{ secrets.RPKM67_DISCORD_WEBHOOK_URL }} \ No newline at end of file