From 9b3aac3d7dd50f5ba644cd0df004baaf37872185 Mon Sep 17 00:00:00 2001 From: mj52951 Date: Mon, 25 Mar 2024 13:01:06 +0100 Subject: [PATCH 1/6] Action for sending notification to Slack --- .github/workflows/send-notification.yml | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/send-notification.yml diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml new file mode 100644 index 0000000..5ecf7b2 --- /dev/null +++ b/.github/workflows/send-notification.yml @@ -0,0 +1,54 @@ +name: "Send notification" + +on: + pull_request: + types: [closed] + +jobs: + send_notification: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v32 + + - name: Check if mainnet was changed + if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-mainnet.json') + run: | + echo "mainnet_changed=true" >> $GITHUB_ENV + + - name: Send Slack notification for mainnet + uses: slackapi/slack-github-action@v1.25.0 + if: ${{ env.mainnet_changed }} + with: + payload: | + { + "environment": "MAINNET", + "pr_url": "${{ github.event.pull_request.html_url }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Check if testnet was changed + if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-test.json') + run: | + echo "testnet_changed=true" >> $GITHUB_ENV + + - name: Send Slack notification for testnet + uses: slackapi/slack-github-action@v1.25.0 + if: ${{ env.testnet_changed }} + with: + payload: | + { + "environment": "TESTNET", + "pr_url": "${{ github.event.pull_request.html_url }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file From 197aa5018a0f603a04e22f33de25308cb2a11dd2 Mon Sep 17 00:00:00 2001 From: mj52951 Date: Mon, 8 Apr 2024 14:53:36 +0200 Subject: [PATCH 2/6] Updated sending notif --- .github/workflows/send-notification.yml | 80 +++++++++++++++++-------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index 5ecf7b2..550f91d 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -1,54 +1,82 @@ name: "Send notification" - on: pull_request: types: [closed] - jobs: send_notification: runs-on: ubuntu-latest if: github.event.pull_request.merged == true - steps: - name: Checkout repository uses: actions/checkout@v2 with: fetch-depth: 0 - + - name: Get changed files id: changed-files uses: tj-actions/changed-files@v32 - - name: Check if mainnet was changed - if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-mainnet.json') + - name: Check if mainnet or testnet were changed + if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-mainnet.json') || contains(steps.changed-files.outputs.all_changed_files, 'shared-config-test.json') run: | - echo "mainnet_changed=true" >> $GITHUB_ENV + echo "environment_changed=true" >> $GITHUB_ENV - - name: Send Slack notification for mainnet - uses: slackapi/slack-github-action@v1.25.0 - if: ${{ env.mainnet_changed }} + - name: Send Slack notification + uses: 8398a7/action-slack@v3 + if: ${{ env.environment_changed }} with: - payload: | + status: custom + fields: all + custom_payload: | { - "environment": "MAINNET", - "pr_url": "${{ github.event.pull_request.html_url }}" + text: `Changes have been detected.\nPlease restart your relayer(s) on the changed environment.\n\n If a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\n For more details feel free to contact the Sygma team.`, + attachments: [{ + color: 'good', + fields: [ + { + title: 'Repository', + value: `${ process.env.AS_REPO }`, + }, + { + title: 'Pull request', + value: `${ process.env.AS_PULL_REQUEST }`, + }, + { + title: 'Author', + value: `${ process.env.AS_AUTHOR }`, + } + ], + }] } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - name: Check if testnet was changed - if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-test.json') - run: | - echo "testnet_changed=true" >> $GITHUB_ENV + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL1 }} - - name: Send Slack notification for testnet - uses: slackapi/slack-github-action@v1.25.0 - if: ${{ env.testnet_changed }} + - name: Send Slack notification + uses: 8398a7/action-slack@v3 + if: ${{ env.environment_changed }} with: - payload: | + status: custom + fields: all + custom_payload: | { - "environment": "TESTNET", - "pr_url": "${{ github.event.pull_request.html_url }}" + text: `Changes have been detected.\nPlease restart your relayer(s) on the changed environment.\n\n If a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\n For more details feel free to contact the Sygma team.`, + attachments: [{ + color: 'good', + fields: [ + { + title: 'Repository', + value: `${ process.env.AS_REPO }`, + }, + { + title: 'Pull request', + value: `${ process.env.AS_PULL_REQUEST }`, + }, + { + title: 'Author', + value: `${ process.env.AS_AUTHOR }`, + }, + ], + }] } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL2 }} From 206630cf3c174a6b9d84c430e8b54e7611f79fa1 Mon Sep 17 00:00:00 2001 From: mj52951 Date: Tue, 9 Apr 2024 10:30:10 +0200 Subject: [PATCH 3/6] Added strategy matrix --- .github/workflows/send-notification.yml | 42 +++++++------------------ 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index 550f91d..bd4c7a4 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -6,6 +6,16 @@ jobs: send_notification: runs-on: ubuntu-latest if: github.event.pull_request.merged == true + strategy: + matrix: + include: + - webhook: SLACK_WEBHOOK_URL1 + - webhook: SLACK_WEBHOOK_URL2 + + env: + SLACK_WEBHOOK_URL1: ${{ secrets.SLACK_WEBHOOK_URL1 }} + SLACK_WEBHOOK_URL2: ${{ secrets.SLACK_WEBHOOK_URL2 }} + steps: - name: Checkout repository uses: actions/checkout@v2 @@ -21,36 +31,6 @@ jobs: run: | echo "environment_changed=true" >> $GITHUB_ENV - - name: Send Slack notification - uses: 8398a7/action-slack@v3 - if: ${{ env.environment_changed }} - with: - status: custom - fields: all - custom_payload: | - { - text: `Changes have been detected.\nPlease restart your relayer(s) on the changed environment.\n\n If a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\n For more details feel free to contact the Sygma team.`, - attachments: [{ - color: 'good', - fields: [ - { - title: 'Repository', - value: `${ process.env.AS_REPO }`, - }, - { - title: 'Pull request', - value: `${ process.env.AS_PULL_REQUEST }`, - }, - { - title: 'Author', - value: `${ process.env.AS_AUTHOR }`, - } - ], - }] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL1 }} - - name: Send Slack notification uses: 8398a7/action-slack@v3 if: ${{ env.environment_changed }} @@ -79,4 +59,4 @@ jobs: }] } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL2 }} + SLACK_WEBHOOK_URL: ${{ secrets[matrix.webhook] }} From 5e971061e78ba44ea5850713dd73eb8925f0286a Mon Sep 17 00:00:00 2001 From: mj52951 Date: Thu, 11 Apr 2024 13:34:37 +0200 Subject: [PATCH 4/6] Added checking for a label Restart Relayers --- .github/workflows/send-notification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index bd4c7a4..70011fe 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -5,7 +5,7 @@ on: jobs: send_notification: runs-on: ubuntu-latest - if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Restart Relayers') strategy: matrix: include: From 63ff59fa35612b8e5f9f1a1700f69141cbe4c228 Mon Sep 17 00:00:00 2001 From: mj52951 Date: Thu, 11 Apr 2024 14:15:36 +0200 Subject: [PATCH 5/6] Changed message and added different checks for mainnet and testnet --- .github/workflows/send-notification.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index 70011fe..0179329 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -15,6 +15,8 @@ jobs: env: SLACK_WEBHOOK_URL1: ${{ secrets.SLACK_WEBHOOK_URL1 }} SLACK_WEBHOOK_URL2: ${{ secrets.SLACK_WEBHOOK_URL2 }} + MAINNET_CHANGED: ":x:" + TESTNET_CHANGED: ":x:" steps: - name: Checkout repository @@ -26,20 +28,28 @@ jobs: id: changed-files uses: tj-actions/changed-files@v32 - - name: Check if mainnet or testnet were changed - if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-mainnet.json') || contains(steps.changed-files.outputs.all_changed_files, 'shared-config-test.json') + - name: Check if mainnet changed + if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-mainnet.json') run: | - echo "environment_changed=true" >> $GITHUB_ENV + echo "ENVIRONMENT_CHANGED=true" >> $GITHUB_ENV + echo "MAINNET_CHANGED=:heavy_check_mark:" >> $GITHUB_ENV + + + - name: Check if testnet changed + if: contains(steps.changed-files.outputs.all_changed_files, 'shared-config-test.json') + run: | + echo "ENVIRONMENT_CHANGED=true" >> $GITHUB_ENV + echo "TESTNET_CHANGED=:heavy_check_mark:" >> $GITHUB_ENV - name: Send Slack notification uses: 8398a7/action-slack@v3 - if: ${{ env.environment_changed }} + if: ${{ env.ENVIRONMENT_CHANGED }} with: status: custom fields: all custom_payload: | { - text: `Changes have been detected.\nPlease restart your relayer(s) on the changed environment.\n\n If a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\n For more details feel free to contact the Sygma team.`, + text: `Changes have been detected.\nPlease restart your relayer(s) on:\n\n*MAINNET* ${{ env.MAINNET_CHANGED }}\n*TESTNET* ${{ env.TESTNET_CHANGED }}\n\nIf a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\nFor more details feel free to contact the Sygma team.`, attachments: [{ color: 'good', fields: [ From fcfd2c07837761483f05c66cf6b75af3df39181e Mon Sep 17 00:00:00 2001 From: mj52951 Date: Thu, 6 Jun 2024 15:07:39 +0200 Subject: [PATCH 6/6] Text minor change --- .github/workflows/send-notification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index 0179329..086a46c 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -49,7 +49,7 @@ jobs: fields: all custom_payload: | { - text: `Changes have been detected.\nPlease restart your relayer(s) on:\n\n*MAINNET* ${{ env.MAINNET_CHANGED }}\n*TESTNET* ${{ env.TESTNET_CHANGED }}\n\nIf a new network was added with these changes, you will have to expand your local relayer(s) configuration.\n\nFor more details feel free to contact the Sygma team.`, + text: `Changes have been detected.\nPlease restart your relayer(s) on:\n\n*MAINNET* ${{ env.MAINNET_CHANGED }}\n*TESTNET* ${{ env.TESTNET_CHANGED }}\n\nIf a new network was added with these changes, you will have to expand the configuration of your local relayer(s).\n\nFor more details feel free to contact the Sygma team.`, attachments: [{ color: 'good', fields: [