Skip to content

Commit

Permalink
chore: fix update snyk pr action (#9564)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanh committed Mar 26, 2024
1 parent ab47ce4 commit 092e5d9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 28 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/snyk-yarn-lock-commit.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .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

0 comments on commit 092e5d9

Please sign in to comment.