From e475c48a0a349214147771bbbef47ac412b89489 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Fri, 17 Jan 2025 16:12:56 -0500 Subject: [PATCH] Fix upgrade.yml workflow --- .github/workflows/upgrade.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml index 3a8b60d5..5f590303 100644 --- a/.github/workflows/upgrade.yml +++ b/.github/workflows/upgrade.yml @@ -5,6 +5,7 @@ on: workflow_dispatch: {} schedule: - cron: 0 0 * * * + jobs: upgrade: name: Upgrade @@ -19,7 +20,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 14.15.0 + node-version: 18.18.0 - name: Install dependencies run: yarn install --check-files --frozen-lockfile - name: Upgrade dependencies @@ -27,22 +28,28 @@ jobs: - name: Find mutations id: create_patch run: |- + echo "Checking for staged changes..." + git status git add . - git diff --staged --patch --exit-code > .repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT - working-directory: ./ + echo "Generating patch file..." + git diff --staged --patch --exit-code > repo.patch || { + echo "Staged changes detected. Patch file created." + echo "patch_created=true" >> $GITHUB_OUTPUT + } - name: Upload patch if: steps.create_patch.outputs.patch_created uses: actions/upload-artifact@v4 with: - name: .repo.patch - path: .repo.patch + name: repo.patch + path: ${{ github.workspace }}/repo.patch overwrite: true pr: name: Create Pull Request needs: upgrade runs-on: ubuntu-latest permissions: - contents: read + contents: write + pull-requests: write if: ${{ needs.upgrade.outputs.patch_created }} steps: - name: Checkout @@ -50,10 +57,10 @@ jobs: - name: Download patch uses: actions/download-artifact@v4 with: - name: .repo.patch + name: repo.patch path: ${{ runner.temp }} - name: Apply patch - run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' + run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' - name: Set git identity run: |- git config user.name "github-actions" @@ -62,7 +69,7 @@ jobs: id: create-pr uses: peter-evans/create-pull-request@v6 with: - token: ${{ secrets.PROJEN_GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} commit-message: |- chore(deps): upgrade dependencies