Skip to content

Commit

Permalink
fix: Warning: ... Please upgrade...
Browse files Browse the repository at this point in the history
```txt
Run echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
```
  • Loading branch information
hamirmahal committed Aug 18, 2023
1 parent 65e85db commit fdc0675
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions .github/workflows/check-node-modules-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,60 @@ jobs:
node-version: 18

- name: Install dependencies
run: yarn install
run: npm install

- name: Get main branch node_modules size
id: main_size
run: echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
- name: Analyze `node_modules` size
id: current_size
run: echo "CURRENT_SIZE=$(du -sh node_modules | awk '{print $1}')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Analyze node_modules size
id: current_size
run: echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main

- name: Remove `node_modules`
run: rm -rf node_modules/

- name: Install dependencies
run: npm install

- name: Get main branch `node_modules` size
id: main_size
run: echo "MAIN_SIZE=$(du -sh node_modules | awk '{print $1}')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Print sizes
run: |
echo "Main branch size: $MAIN_SIZE"
echo "Current branch size: $CURRENT_SIZE"
- name: Compare sizes and send alert
if: ${{ steps.current_size.outputs.size != steps.main_size.outputs.size }}
if: ${{ env.CURRENT_SIZE != env.MAIN_SIZE }}
run: |
echo "Node Modules size has changed!"
echo "Main branch size: ${{ steps.main_size.outputs.size }}"
echo "Current branch size: ${{ steps.current_size.outputs.size }}"
echo "Main branch size: $MAIN_SIZE"
echo "Current branch size: $CURRENT_SIZE"
# Add your alerting mechanism here, such as sending a Slack notification, creating an issue, etc.
- name: Create comment with output
if: ${{ env.CURRENT_SIZE != env.MAIN_SIZE }}
uses: actions/github-script@v6
with:
script: |
const body = `\`node_modules/\` size has changed!\n
Main branch size: ${process.env.MAIN_SIZE}\n
Current branch size: ${process.env.CURRENT_SIZE}`
// https://stackoverflow.com/questions/58066966/commenting-a-pull-request-in-a-github-action/76215842#76215842
github.rest.issues.createComment({
body,
issue_number: (await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})).data[0].number,
owner: context.repo.owner,
repo: context.repo.repo,
});

0 comments on commit fdc0675

Please sign in to comment.