From f0046f543230bdf64df19cfbb7324aaefd70a689 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 11:58:03 +0100 Subject: [PATCH 01/17] fix: change number --- src/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/action.ts b/src/action.ts index a1eaf10..ea71915 100644 --- a/src/action.ts +++ b/src/action.ts @@ -13,7 +13,7 @@ export class Action { const name = inputs.name || "World"; this.logger.info(`Hello ${name}`); await this.sleep(3000); - this.logger.info("Change: 5"); + this.logger.info("Change: 6"); this.logger.info("Finished github-action-nodejs-template"); } From 239b75fd7be92d88957d9374666431da227d8ecc Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:04:07 +0100 Subject: [PATCH 02/17] fix: upload artifact --- .github/workflows/check-dist.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 3c966be..b75cb2d 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -27,9 +27,15 @@ jobs: - name: Rebuild the index.js file run: npm run build - name: Compare the expected and actual dist/ directories + id: diff run: | if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then echo "Detected uncommitted changes after build. See status below:" git diff exit 1 fi + - uses: actions/upload-artifact@v4 + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + with: + name: dist + path: dist/ From 7c225a7da2b5ef653b76cd0ecc503d50284caac7 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:16:54 +0100 Subject: [PATCH 03/17] fix: add cache --- .github/workflows/check-dist.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index b75cb2d..aa35129 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -18,11 +18,19 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache Dependencies ⌛️ + uses: actions/cache@v4 + id: cache-node-modules + with: + path: 'node_modules' + key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}-${{ hashFiles('.github/workflows/node.yml') }} - name: Setup Node uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' + cache: npm - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' run: npm ci - name: Rebuild the index.js file run: npm run build From a8ec1cefef111652cd9facdac2bdf922819740e2 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:20:57 +0100 Subject: [PATCH 04/17] fix: improve tip message --- .github/workflows/check-dist.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index aa35129..e4ffd29 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -38,7 +38,9 @@ jobs: id: diff run: | if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" + echo "❌ Detected uncommitted changes after build" + echo: "💡 To fix it, you need to run 'npm run build' and commit and push the dist folder changes" + echo: "👇 See status below" git diff exit 1 fi From 0710a5f351e0c3ddcaa1f6eda68587bfe39e8d59 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:22:31 +0100 Subject: [PATCH 05/17] fix: delete unnecessary : in the echo --- .github/workflows/check-dist.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index e4ffd29..8793b1a 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -39,8 +39,8 @@ jobs: run: | if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then echo "❌ Detected uncommitted changes after build" - echo: "💡 To fix it, you need to run 'npm run build' and commit and push the dist folder changes" - echo: "👇 See status below" + echo "💡 To fix it, you need to run 'npm run build' and commit and push the dist folder changes" + echo "👇 See status below" git diff exit 1 fi From b41ceccb6918d39d56d999640246e46159a4c8d0 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:43:08 +0100 Subject: [PATCH 06/17] fix: add comment in the pr --- .github/workflows/check-dist.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 8793b1a..c81436f 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -34,6 +34,20 @@ jobs: run: npm ci - name: Rebuild the index.js file run: npm run build + - uses: peter-evans/find-comment@v3 + if: ${{ github.event_name == 'pull_request' }} + id: find-comment + with: + issue-number: ${{ github.event.number }} + comment-author: 'github-actions[bot]' + - name: Delete comment + uses: sandeshjangam/comment-actions@v1 + if: ${{ steps.find-comment.outputs.comment-id != '' }} + with: + type: delete + comment_id: ${{ steps.find-comment.outputs.comment-id }} + comment-author: 'github-actions[bot]' + body-include: '❌ Detected mismatch in the `dist` directory.' - name: Compare the expected and actual dist/ directories id: diff run: | @@ -46,6 +60,19 @@ jobs: fi - uses: actions/upload-artifact@v4 if: ${{ failure() && steps.diff.conclusion == 'failure' }} + id: artifact-dist with: name: dist path: dist/ + - uses: peter-evans/create-or-update-comment@v4 + if: ${{ failure() && steps.diff.conclusion == 'failure' && steps.find-comment.outputs.comment-id != '' }} + with: + issue-number: ${{ github.event.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + edit-mode: 'replace' + body: | + ❌ Detected mismatch in the `dist` directory. + + 💡 Tip: to fix this issue you need to run `npm run build`, commit and push the `dist` folder changes. + + You can see [here](${{ steps.artifact-upload-step.outputs.artifact-url }}) more details about the mismatch. From 7e38f2ed359734d427d27460e69a6bd778533c1d Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:51:48 +0100 Subject: [PATCH 07/17] fix: delete comment in pr and how to find it --- .github/workflows/check-dist.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index c81436f..19b6f72 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -40,14 +40,15 @@ jobs: with: issue-number: ${{ github.event.number }} comment-author: 'github-actions[bot]' + body-includes: '❌ Detected mismatch in the `dist` directory.' - name: Delete comment uses: sandeshjangam/comment-actions@v1 if: ${{ steps.find-comment.outputs.comment-id != '' }} with: type: delete comment_id: ${{ steps.find-comment.outputs.comment-id }} - comment-author: 'github-actions[bot]' - body-include: '❌ Detected mismatch in the `dist` directory.' + author: 'github-actions[bot]' + body: '❌ Detected mismatch in the `dist` directory.' - name: Compare the expected and actual dist/ directories id: diff run: | @@ -65,7 +66,7 @@ jobs: name: dist path: dist/ - uses: peter-evans/create-or-update-comment@v4 - if: ${{ failure() && steps.diff.conclusion == 'failure' && steps.find-comment.outputs.comment-id != '' }} + if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: issue-number: ${{ github.event.number }} comment-id: ${{ steps.find-comment.outputs.comment-id }} From 5d7ed7502fae3f790450c22d55dc517949899965 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:53:33 +0100 Subject: [PATCH 08/17] fix: change step id --- .github/workflows/check-dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 19b6f72..bc2cff6 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -76,4 +76,4 @@ jobs: 💡 Tip: to fix this issue you need to run `npm run build`, commit and push the `dist` folder changes. - You can see [here](${{ steps.artifact-upload-step.outputs.artifact-url }}) more details about the mismatch. + You can see [here](${{ steps.artifact-dist.outputs.artifact-url }}) more details about the mismatch. From c9b9389a713d8338a7238e4a9d5f3de52ac60ec6 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:57:05 +0100 Subject: [PATCH 09/17] fix: add write permissions --- .github/workflows/check-dist.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index bc2cff6..954875e 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -15,7 +15,8 @@ on: jobs: check-dist: runs-on: ubuntu-latest - + permissions: + contents: write steps: - uses: actions/checkout@v4 - name: Cache Dependencies ⌛️ From b95ef3aed186e347e55b2dc9820e193f1e445661 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 12:58:56 +0100 Subject: [PATCH 10/17] fix: add write permissions for pr --- .github/workflows/check-dist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 954875e..9191945 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -17,6 +17,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + pull-requests: write steps: - uses: actions/checkout@v4 - name: Cache Dependencies ⌛️ From 0fc65a519b2b6797dd6a9c78bd4e13b77545cb51 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:00:53 +0100 Subject: [PATCH 11/17] fix: remove link to artifact --- .github/workflows/check-dist.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 9191945..5247305 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -77,5 +77,3 @@ jobs: ❌ Detected mismatch in the `dist` directory. 💡 Tip: to fix this issue you need to run `npm run build`, commit and push the `dist` folder changes. - - You can see [here](${{ steps.artifact-dist.outputs.artifact-url }}) more details about the mismatch. From d7fdf164cfba1efc1e07e9474316e186b8d23093 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:03:58 +0100 Subject: [PATCH 12/17] fix: change number --- src/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/action.ts b/src/action.ts index ea71915..ff42d9c 100644 --- a/src/action.ts +++ b/src/action.ts @@ -13,7 +13,7 @@ export class Action { const name = inputs.name || "World"; this.logger.info(`Hello ${name}`); await this.sleep(3000); - this.logger.info("Change: 6"); + this.logger.info("Change: 7"); this.logger.info("Finished github-action-nodejs-template"); } From 0bf47ad97ad0ab1ecbf7a8f4e1a9fa07aa5dc9ac Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:06:06 +0100 Subject: [PATCH 13/17] fix: remove comment id and edit mode --- .github/workflows/check-dist.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 5247305..f60cedd 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -71,8 +71,6 @@ jobs: if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: issue-number: ${{ github.event.number }} - comment-id: ${{ steps.find-comment.outputs.comment-id }} - edit-mode: 'replace' body: | ❌ Detected mismatch in the `dist` directory. From 71a9981b0fac319af15c80c9ae29ad918c376634 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:07:24 +0100 Subject: [PATCH 14/17] fix: change number --- src/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/action.ts b/src/action.ts index ff42d9c..b400d76 100644 --- a/src/action.ts +++ b/src/action.ts @@ -13,7 +13,7 @@ export class Action { const name = inputs.name || "World"; this.logger.info(`Hello ${name}`); await this.sleep(3000); - this.logger.info("Change: 7"); + this.logger.info("Change: 8"); this.logger.info("Finished github-action-nodejs-template"); } From 4572502d990a0aaea2ddd7e094caf2fb9df660ca Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:08:20 +0100 Subject: [PATCH 15/17] fix: check is pull request --- .github/workflows/check-dist.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index f60cedd..7b88608 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -45,7 +45,7 @@ jobs: body-includes: '❌ Detected mismatch in the `dist` directory.' - name: Delete comment uses: sandeshjangam/comment-actions@v1 - if: ${{ steps.find-comment.outputs.comment-id != '' }} + if: ${{ github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != '' }} with: type: delete comment_id: ${{ steps.find-comment.outputs.comment-id }} @@ -68,7 +68,7 @@ jobs: name: dist path: dist/ - uses: peter-evans/create-or-update-comment@v4 - if: ${{ failure() && steps.diff.conclusion == 'failure' }} + if: ${{ failure() && steps.diff.conclusion == 'failure' && github.event_name == 'pull_request' }} with: issue-number: ${{ github.event.number }} body: | From 33acf51ebe1967cb8c10459ffa19317a38bed881 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:18:31 +0100 Subject: [PATCH 16/17] fix: delete comment using another action --- .github/workflows/check-dist.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 7b88608..ead95a2 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -43,14 +43,18 @@ jobs: issue-number: ${{ github.event.number }} comment-author: 'github-actions[bot]' body-includes: '❌ Detected mismatch in the `dist` directory.' - - name: Delete comment - uses: sandeshjangam/comment-actions@v1 + - name: Delete old comment + uses: actions/github-script@v7 if: ${{ github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != '' }} with: - type: delete - comment_id: ${{ steps.find-comment.outputs.comment-id }} - author: 'github-actions[bot]' - body: '❌ Detected mismatch in the `dist` directory.' + result-encoding: string + retries: 3 + script: | + github.rest.issues.deleteComment({ + comment_id: ${{ steps.find-comment.outputs.comment-id }}, + owner: context.repo.owner, + repo: context.repo.repo, + }) - name: Compare the expected and actual dist/ directories id: diff run: | From f67a62b17b48af92f74ef377067e8cf4822694d5 Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 18 Feb 2024 13:20:33 +0100 Subject: [PATCH 17/17] fix: build dist --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index b304edb..c4a3e20 100644 --- a/dist/index.js +++ b/dist/index.js @@ -24722,7 +24722,7 @@ class Action { const name = inputs.name || "World"; this.logger.info(`Hello ${name}`); await this.sleep(3000); - this.logger.info("Change: 5"); + this.logger.info("Change: 8"); this.logger.info("Finished github-action-nodejs-template"); } sleep(milliseconds) {