From 1d2245baa14b839f8cfd428379bfe0a967f96487 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 05:39:30 +0330 Subject: [PATCH 01/11] ci: add pr-comment workflow --- .github/workflows/pr-comment.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 0000000..c20294d --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,22 @@ +name: Pull request comment after merge +on: + pull_request: + types: + - closed + +jobs: + comment: + # if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Add comment to PR + env: + URL: ${{ github.event.issue.comments_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl \ + -X POST \ + $URL \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + --data '{ "body": "test" }' From 871737c668a2c8090c20284583c49edd9c001f97 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 05:49:07 +0330 Subject: [PATCH 02/11] ci: use actions/github-script in pr-comment workflow --- .github/workflows/pr-comment.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index c20294d..b90d833 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -9,14 +9,12 @@ jobs: # if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - name: Add comment to PR - env: - URL: ${{ github.event.issue.comments_url }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl \ - -X POST \ - $URL \ - -H "Content-Type: application/json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - --data '{ "body": "test" }' + - uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '👋 Thanks for reporting!' + }) From 0c325b079690d929163bac680c9721d0a2b9265e Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:01:07 +0330 Subject: [PATCH 03/11] ci: add username to pr-comment --- .github/workflows/pr-comment.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index b90d833..aa2fd1b 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -8,13 +8,15 @@ jobs: comment: # if: github.event.pull_request.merged == true runs-on: ubuntu-latest + env: + USERNAME: ${{ github.event.pull_request.user.name }} steps: - uses: actions/github-script@v6 with: script: | github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '👋 Thanks for reporting!' + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '👋 Thank you $USERNAME!' }) From 483abf3c38f50fde266302aedefea2f10a2de570 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:05:08 +0330 Subject: [PATCH 04/11] ci: fix username in pr-comment --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index aa2fd1b..234c9c4 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -18,5 +18,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '👋 Thank you $USERNAME!' + body: '👋 Thank you ${{ env.USERNAME }}!' }) From 3a57b90dc6bfd88c7db7b6ef18adb5c08243435a Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:06:59 +0330 Subject: [PATCH 05/11] ci: dump environment variables --- .github/workflows/pr-comment.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 234c9c4..34f438d 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -11,6 +11,8 @@ jobs: env: USERNAME: ${{ github.event.pull_request.user.name }} steps: + - name: dump env + run: env - uses: actions/github-script@v6 with: script: | From 6f442b11efb3cb3ebfc077e1d32a60ea2cdbe574 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:11:46 +0330 Subject: [PATCH 06/11] ci: dump github context --- .github/workflows/pr-comment.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 34f438d..8c6c51c 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -13,6 +13,10 @@ jobs: steps: - name: dump env run: env + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJSON(github) }} + run: echo "$GITHUB_CONTEXT" - uses: actions/github-script@v6 with: script: | From 313af98ebb8b86742b8feacd55cec2e2b0098a93 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:19:30 +0330 Subject: [PATCH 07/11] ci: use user.login instead of name --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 8c6c51c..21965c8 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -9,7 +9,7 @@ jobs: # if: github.event.pull_request.merged == true runs-on: ubuntu-latest env: - USERNAME: ${{ github.event.pull_request.user.name }} + USERNAME: ${{ github.event.pull_request.user.login }} steps: - name: dump env run: env From 9777a20a8e2dc978fa1e8d60840513546b95ee5e Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:25:58 +0330 Subject: [PATCH 08/11] ci: mention user --- .github/workflows/pr-comment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 21965c8..3b3dabe 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -10,6 +10,7 @@ jobs: runs-on: ubuntu-latest env: USERNAME: ${{ github.event.pull_request.user.login }} + USER_URL: ${{ github.event.pull_request.user.html_url }} steps: - name: dump env run: env @@ -24,5 +25,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '👋 Thank you ${{ env.USERNAME }}!' + body: '👋 Thank you @[${{ env.USERNAME }}](${{ env.USER_URL }})!' }) From 8ecee581778ada02e63f3a667b99db13e36a030b Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:31:26 +0330 Subject: [PATCH 09/11] ci: remove dumps from pr-comment --- .github/workflows/pr-comment.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 3b3dabe..f0c8484 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -12,13 +12,8 @@ jobs: USERNAME: ${{ github.event.pull_request.user.login }} USER_URL: ${{ github.event.pull_request.user.html_url }} steps: - - name: dump env - run: env - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/github-script@v6 + - name: "Comment on the PR" + uses: actions/github-script@v6 with: script: | github.rest.issues.createComment({ From 902ccf82deddc8a42ac2d854059eff2d6d9f72fa Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:31:39 +0330 Subject: [PATCH 10/11] ci: update comment message --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index f0c8484..28b1b92 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -20,5 +20,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '👋 Thank you @[${{ env.USERNAME }}](${{ env.USER_URL }})!' + body: 'Thank you [@${{ env.USERNAME }}](${{ env.USER_URL }}) ❤️\nYour changes has been merged to the `dev` branch. 🎉' }) From 81d51ae777564e7d1e38bda224e6ce1d3a3102e4 Mon Sep 17 00:00:00 2001 From: Amir Hossein Karimi Date: Thu, 11 Jan 2024 06:46:14 +0330 Subject: [PATCH 11/11] ci: comment only for merged pr --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 28b1b92..b24f1ac 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -6,7 +6,7 @@ on: jobs: comment: - # if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true runs-on: ubuntu-latest env: USERNAME: ${{ github.event.pull_request.user.login }}