Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,67 @@ on:
jobs:
check-dist:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write
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
- 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]'
body-includes: '❌ Detected mismatch in the `dist` directory.'
- name: Delete old comment
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != '' }}
with:
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: |
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
- 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' && github.event_name == 'pull_request' }}
with:
issue-number: ${{ github.event.number }}
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.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: 8");
this.logger.info("Finished github-action-nodejs-template");
}

Expand Down