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: simplify validate workflow #15

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
10 changes: 3 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Needed to push changes back to the repo
fetch-depth: 0
fetch-depth: 2

# Must be done before setup-node.
- name: Enable Corepack
Expand All @@ -36,11 +35,8 @@ jobs:
id: find-json
run: |
# Get the list of added JSON files in the records/new/ directory
ADDED_FILES=$(git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --diff-filter=A --name-only | grep '^records/new/.*\.json$' || true)
echo "NEW_JSON_FILES=$ADDED_FILES" >> $GITHUB_ENV
if [ -z "$ADDED_FILES" ]; then
echo "No new JSON files found."
fi
ADDED_FILES=$(git diff HEAD^..HEAD --diff-filter=A --name-only records/new | grep '/.*\.json$' || true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work when there are multiple commits in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, HEAD^ references the base branch, and HEAD the merge commit.

echo "NEW_JSON_FILES=$ADDED_FILES" >> "$GITHUB_ENV"

- name: Validate files
if: env.NEW_JSON_FILES
Expand Down
Loading