From 092e5d95bf75ce2db772669971e28f22e6ee8679 Mon Sep 17 00:00:00 2001 From: Jordan Husney Date: Mon, 25 Mar 2024 18:07:49 -0700 Subject: [PATCH] chore: fix update snyk pr action (#9564) --- .github/workflows/snyk-yarn-lock-commit.yml | 28 ----------- .github/workflows/synk-yarn-lock-commit.yml | 52 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/snyk-yarn-lock-commit.yml create mode 100644 .github/workflows/synk-yarn-lock-commit.yml diff --git a/.github/workflows/snyk-yarn-lock-commit.yml b/.github/workflows/snyk-yarn-lock-commit.yml deleted file mode 100644 index f4705ec4b79..00000000000 --- a/.github/workflows/snyk-yarn-lock-commit.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Update Snyk PR to add yarn.lock - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - update-snyk-pr: - if: contains(github.event.pull_request.title, '[Snyk]') - runs-on: ubuntu-latest - - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create one - - - name: Install dependencies - run: yarn install - - - name: Commit yarn.lock to the PR branch - run: | - git config --global user.email "action@github.com" - git config --global user.name "GitHub Action" - git add yarn.lock - git commit -m "Update yarn.lock" || echo "No changes to commit" - git push diff --git a/.github/workflows/synk-yarn-lock-commit.yml b/.github/workflows/synk-yarn-lock-commit.yml new file mode 100644 index 00000000000..6ac67f37aa9 --- /dev/null +++ b/.github/workflows/synk-yarn-lock-commit.yml @@ -0,0 +1,52 @@ +name: Update Snyk PR to add yarn.lock + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + update-snyk-pr: + if: contains(github.event.pull_request.title, '[Snyk]') + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create one + + - name: Setup environment variables + run: | + ACTION_VERSION=$(grep '"version":' package.json | cut -d\" -f4) + echo "ACTION_VERSION=${ACTION_VERSION}" >> $GITHUB_ENV + echo "NODE_VERSION=$(jq -r -j '.engines.node|ltrimstr("^")' package.json)" >> $GITHUB_ENV + + DOCKER_REPOSITORY_FOR_REF=${{ secrets.GCP_AR_PARABOL_DEV }} + echo "DOCKER_REPOSITORY_FOR_REF=${{ secrets.GCP_AR_PARABOL_DEV }}" >> $GITHUB_ENV + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: package.json + # Caching yarn dir & running yarn install is too slow + # Instead, we aggressively cache node_modules below to avoid calling install + + - name: Get cached node modules + id: cache + uses: actions/cache@v3 + with: + path: | + **/node_modules + key: node_modules-${{ runner.arch }}-${{ env.NODE_VERSION }}-${{ hashFiles('yarn.lock') }} + + - name: Install node_modules + run: yarn install + + - name: Commit yarn.lock to the PR branch + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + git add yarn.lock + git commit -m "Update yarn.lock" || echo "No changes to commit" + git push