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 f93009e
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions .github/workflows/check-node-modules-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,47 @@ jobs:
- name: Install dependencies
run: yarn install

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

- name: Analyze node_modules size
- name: Analyze `node_modules` size
id: current_size
run: echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
run: echo "CURRENT_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 f93009e

Please sign in to comment.