Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix update snyk pr action #9564

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -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
Loading