From b442b1935b0a666f56013595f45543605e1f465a Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 11:45:22 +0100 Subject: [PATCH 1/7] wip --- .github/workflows/linear-notification.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linear-notification.yml b/.github/workflows/linear-notification.yml index eec0a0e..e8fcdc6 100644 --- a/.github/workflows/linear-notification.yml +++ b/.github/workflows/linear-notification.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Create Linear ticket id: createIssue - uses: ctriolo/action-create-linear-issue@v0.5 + uses: ctriolo/action-create-linear-issue@v0.7 with: linear-api-key: ${{ secrets.LINEAR_API_KEY }} linear-team-key: "ECO" @@ -22,9 +22,9 @@ jobs: linear-attachment-title: ${{ github.event.pull_request.title }} - name: Create comment for Linear ticket link - uses: marocchino/sticky-pull-request-comment@v2.8.0 + uses: marocchino/sticky-pull-request-comment@v2.9.1 with: - GITHUB_TOKEN: ${{ secrets.CLERK_COOKIE_PAT }} + GITHUB_TOKEN: ${{ secrets.PAT }} number: ${{ github.event.issue.number }} header: linear-issue-url message: | From d16169dc28ca0aeb440e7ad5334a2ddd7fc57d59 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 11:52:02 +0100 Subject: [PATCH 2/7] debug --- .github/workflows/slack-notification.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index aedf084..1edd23d 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -14,6 +14,8 @@ jobs: with: fetch-depth: 0 show-progress: false + - name: Debug body + run: echo ${{ github.event.pull_request.body }} - name: Convert PR body to Slack format id: slackify uses: LoveToKnow/slackify-markdown-action@v1.1.1 From ae6beb993e8022c5757352598fd1ae273f8bc933 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 11:54:14 +0100 Subject: [PATCH 3/7] debug --- .github/workflows/slack-notification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index 1edd23d..b41524b 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -2,7 +2,7 @@ name: Slack Notification on: pull_request: - types: [opened] + types: [opened, reopened] jobs: slack-notify: From bf4687f71983c66abe9c62a44e8844e58f6859a9 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 12:03:14 +0100 Subject: [PATCH 4/7] debug --- .github/workflows/slack-notification.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index b41524b..ff7c6bd 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -8,6 +8,8 @@ jobs: slack-notify: name: Slack Notification runs-on: ubuntu-latest + env: + PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} steps: - name: Checkout repo uses: actions/checkout@v4 @@ -15,7 +17,7 @@ jobs: fetch-depth: 0 show-progress: false - name: Debug body - run: echo ${{ github.event.pull_request.body }} + run: echo $PULL_REQUEST_BODY - name: Convert PR body to Slack format id: slackify uses: LoveToKnow/slackify-markdown-action@v1.1.1 From e6ba0e6ca2d718c096085a73526b5ae9319d6d30 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 13:43:26 +0100 Subject: [PATCH 5/7] updates --- .github/utils/slack-notify.mjs | 8 +++++--- .github/workflows/linear-notification.yml | 9 --------- .github/workflows/slack-notification.yml | 10 +++++----- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/utils/slack-notify.mjs b/.github/utils/slack-notify.mjs index 41ca8e5..a49a50e 100644 --- a/.github/utils/slack-notify.mjs +++ b/.github/utils/slack-notify.mjs @@ -62,9 +62,11 @@ const createActor = username => { }; const run = async () => { - const { title, user, html_url } = JSON.parse(process.argv[2]); - const body = process.argv[3]; - const actor = createActor(user.login); + // Input arguments order will be: title actor html_url body + const title = process.argv[2]; + const actor = process.argv[3]; + const html_url = process.argv[4]; + const body = process.argv[5]; const formatter = formatters['slack']; if (!formatter) { diff --git a/.github/workflows/linear-notification.yml b/.github/workflows/linear-notification.yml index e8fcdc6..841c93b 100644 --- a/.github/workflows/linear-notification.yml +++ b/.github/workflows/linear-notification.yml @@ -20,12 +20,3 @@ jobs: linear-issue-description: ${{ github.event.pull_request.body }} linear-attachment-url: ${{ github.event.pull_request.html_url }} linear-attachment-title: ${{ github.event.pull_request.title }} - - - name: Create comment for Linear ticket link - uses: marocchino/sticky-pull-request-comment@v2.9.1 - with: - GITHUB_TOKEN: ${{ secrets.PAT }} - number: ${{ github.event.issue.number }} - header: linear-issue-url - message: | - A Linear ticket has been created for this PR: ${{ steps.createIssue.outputs.linear-issue-url }} \ No newline at end of file diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index ff7c6bd..e4f78ff 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -16,19 +16,19 @@ jobs: with: fetch-depth: 0 show-progress: false - - name: Debug body - run: echo $PULL_REQUEST_BODY - name: Convert PR body to Slack format id: slackify uses: LoveToKnow/slackify-markdown-action@v1.1.1 with: - text: ${{ github.event.pull_request.body }} + text: ${{ env.PULL_REQUEST_BODY }} - name: Generate notification payload id: notification env: - PULL_REQUEST_DATA: ${{ toJson(github.event.pull_request) }} + TITLE: ${{ github.event.pull_request.title }} + USER_LOGIN: ${{ github.event.pull_request.user.login }} + HTML_URL: ${{ github.event.pull_request.html_url }} run: | - payload=$(node ./.github/utils/slack-notify.mjs '${{ env.PULL_REQUEST_DATA }}' '${{ steps.slackify.outputs.text }}') + payload=$(node ./.github/utils/slack-notify.mjs '${{ env.TITLE }}' '${{ env.USER_LOGIN }}' '${{ env.HTML_URL }}' '${{ steps.slackify.outputs.text }}') echo "payload=${payload//$'\n'/'%0A'}" >> $GITHUB_OUTPUT - name: Send PR to Slack id: slack From 483f23540596f40fbcf25f1133c7f9ca7fa83468 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 14:01:25 +0100 Subject: [PATCH 6/7] update --- .github/utils/slack-notify.mjs | 5 +++-- .github/workflows/slack-notification.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/utils/slack-notify.mjs b/.github/utils/slack-notify.mjs index a49a50e..acddc95 100644 --- a/.github/utils/slack-notify.mjs +++ b/.github/utils/slack-notify.mjs @@ -37,7 +37,7 @@ const slackFormatter = { }); const blocks = []; - blocks.push(header(`openapi-specs: ${title}`)); + blocks.push(header(title)); blocks.push(markdown(body)); blocks.push(markdown('\n')); @@ -64,9 +64,10 @@ const createActor = username => { const run = async () => { // Input arguments order will be: title actor html_url body const title = process.argv[2]; - const actor = process.argv[3]; + const user_login = process.argv[3]; const html_url = process.argv[4]; const body = process.argv[5]; + const actor = createActor(user_login); const formatter = formatters['slack']; if (!formatter) { diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index e4f78ff..73e7ed2 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -36,5 +36,5 @@ jobs: with: payload: ${{ steps.notification.outputs.payload }} env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CHANGELOG_WEBHOOK_URL }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file From 616f8c273e66618efc7576d67fb17cec9d6ab9a5 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 23 Jan 2025 14:03:13 +0100 Subject: [PATCH 7/7] remove debug stuff --- .github/workflows/slack-notification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index 73e7ed2..94dce92 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -2,7 +2,7 @@ name: Slack Notification on: pull_request: - types: [opened, reopened] + types: [opened] jobs: slack-notify: