Skip to content

use GraphQL call instead of git push #19

use GraphQL call instead of git push

use GraphQL call instead of git push #19

Workflow file for this run

name: Process newly added JSON
on:
pull_request_target:
types: [closed]
branches:
- main
permissions:
contents: write
concurrency:
group: process-json-${{ github.ref }}
cancel-in-progress: true
jobs:
process-json:
# Only run if the PR was merged
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: 2
persist-credentials: false
# Must be done before setup-node.
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "yarn"
cache-dependency-path: actions/yarn.lock
- name: Install Dependencies
run: yarn install --frozen-lockfile
working-directory: ./actions
- name: Find newly added JSON files
id: find-json
run: |
# Get the list of added JSON files in the records/new/ directory
ADDED_FILES=$(git diff HEAD^ --diff-filter=A --name-only records/new | grep '/.*\.json$' || true)
echo "NEW_JSON_FILES=$ADDED_FILES" >> "$GITHUB_ENV"
- name: Process and move files
if: env.NEW_JSON_FILES
env:
BLUESKY_IDENTIFIER_NODEJS_ORG: nodejs.org
BLUESKY_APP_PASSWORD_NODEJS_ORG: ${{ secrets.BLUESKY_APP_PASSWORD_NODEJS_ORG }}
run: |
for file in $NEW_JSON_FILES; do
echo "Processing $file..."
node actions/process.js "$file"
done
- name: Commit and push changes
if: env.NEW_JSON_FILES
run: |
git add records/
node actions/lib/createCommitOnBranch.mjs \
"$GITHUB_REPOSITORY" \
"main" \
"$(git rev-parse HEAD)" \
"$(git diff HEAD --diff-filter=d --name-only --format=)" \
"$(git diff HEAD --diff-filter=D --name-only --format=)" \
"Process new JSON files from #${{ github.event.pull_request.number }}"
env:
GH_TOKEN: ${{ github.token }}