From c77c30ed4003406241277ca8968bc2abc96fc240 Mon Sep 17 00:00:00 2001 From: Zimo Li <7163127+lzm0@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:51:33 -0400 Subject: [PATCH] Upload regenerated yarn.lock on failure --- yarn/action.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/yarn/action.yml b/yarn/action.yml index f23abf5..422e6a8 100644 --- a/yarn/action.yml +++ b/yarn/action.yml @@ -195,10 +195,35 @@ runs: working-directory: ${{ inputs.working-directory }} - name: Install Dependencies + id: install-dependencies run: yarn install shell: bash working-directory: ${{ inputs.working-directory }} + - name: Regenerate yarn.lock on failure + if: ${{ failure() && steps.install-dependencies.conclusion == 'failure' }} + shell: bash + env: + YARN_CHECKSUM_BEHAVIOR: update + run: | + yarn install + ( + echo '# Bad `yarn.lock`' + echo '## Bad local cache' + echo 'This could be caused by bad locally cached packages.' + echo 'Try running: [`yarn cache clean --all`](https://yarnpkg.com/cli/cache/clean#options)' + echo '## Generated `yarn.lock` file' + echo 'You can retrieve the `yarn.lock` file from artifacts (above)' + ) >> "$GITHUB_STEP_SUMMARY" + working-directory: ${{ inputs.working-directory }} + + - name: Upload regenerated yarn.lock on failure + if: ${{ failure() && steps.install-dependencies.conclusion == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.working-directory != '.' && format('{0}-', inputs.working-directory) || '' }}yarn.lock + path: ${{ inputs.working-directory }}/yarn.lock + - name: Build run: ${{ inputs.yarn-build-command }} shell: bash