Skip to content

Commit e02cc9d

Browse files
authored
ci: update sync-headers to close old PRs, better PR text (#44)
1 parent d5cfe19 commit e02cc9d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.github/workflows/sync-headers.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,28 @@ jobs:
3939
echo "Branch does not exists."
4040
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
4141
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
42+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
4243
fi
4344
fi
4445
- name: Create Pull Request
45-
uses: peter-evans/create-pull-request@v4
46+
id: cpr
47+
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
4648
if: ${{ steps.check-changes.outputs.BRANCH_NAME }}
4749
with:
4850
branch: ${{ steps.check-changes.outputs.BRANCH_NAME }}
4951
commit-message: ${{ steps.check-changes.outputs.COMMIT_MESSAGE }}
5052
title: ${{ steps.check-changes.outputs.COMMIT_MESSAGE }}
5153
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
52-
body: null
54+
body: Automated sync of headers with Node.js ${{ steps.check-changes.outputs.VERSION }}
55+
labels: headers
5356
delete-branch: true
57+
- name: Close existing PRs
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
if: ${{ steps.cpr.outputs.pull-request-number }}
61+
run: |
62+
gh pr list --json number,author,title,labels --jq '[ .[] | select(.author.login == "app/github-actions" and .number != ${{ steps.cpr.outputs.pull-request-number }} and (.labels[]| select(.name =="headers" )))]' | jq -c '.[]' |
63+
while IFS=$"\n" read -r c; do
64+
pr_number=$(echo "$c" | jq -r '.number')
65+
gh pr close $pr_number --delete-branch --comment "Closing in favor of [#${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})."
66+
done

scripts/update-headers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async function main() {
160160
},
161161
});
162162

163-
console.log(`Update headers from nodejs/node tag ${tag}`);
163+
console.log(`feat: update headers from nodejs/node tag ${tag}`);
164164

165165
const files = ['js_native_api_types.h', 'js_native_api.h', 'node_api_types.h', 'node_api.h'];
166166

0 commit comments

Comments
 (0)