Skip to content

Commit 2c2f696

Browse files
panvaaduh95
authored andcommitted
tools: avoid rewriting same-version OpenSSL updates
Replay the existing update branch onto the current target branch before running the updater on scheduled runs. Its version check then skips the same version without rewriting the PR, preserving approvals and CI. This also carries contributor commits into a newer update. Manual dispatches bypass the replay so the update can still be regenerated. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #66999 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent faf48bf commit 2c2f696

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎.github/workflows/update-openssl.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313

1414
permissions:
1515
contents: read
16+
pull-requests: read
1617

1718
jobs:
1819
openssl-update:
@@ -26,6 +27,7 @@ jobs:
2627
env:
2728
TARGET_BRANCH: ${{ github.ref_name }}
2829
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
30+
PR_BRANCH: actions/${{ github.ref_name != github.event.repository.default_branch && format('{0}/', github.ref_name) || '' }}tools-update-openssl
2931
steps:
3032
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3133
with:
@@ -37,6 +39,20 @@ jobs:
3739
if [ "$TARGET_BRANCH" != "$DEFAULT_BRANCH" ]; then
3840
echo "PR_TITLE_PREFIX=[${TARGET_BRANCH%-staging}] " >> "$GITHUB_ENV"
3941
fi
42+
- name: Apply existing OpenSSL update
43+
if: github.event_name != 'workflow_dispatch'
44+
shell: bash
45+
run: |
46+
commit_list=$(gh pr list --repo "$GITHUB_REPOSITORY" \
47+
--head "$PR_BRANCH" --base "$TARGET_BRANCH" --state open \
48+
--json commits,isCrossRepository \
49+
--jq 'first(.[] | select(.isCrossRepository | not)).commits[]?.oid')
50+
if [ -n "$commit_list" ]; then
51+
git fetch --depth=2 --no-tags origin $commit_list
52+
git cherry-pick --empty=drop $commit_list
53+
fi
54+
env:
55+
GH_TOKEN: ${{ github.token }}
4056
- name: Check and download new OpenSSL version
4157
run: |
4258
./tools/dep_updaters/update-openssl.sh download \
@@ -72,6 +88,6 @@ jobs:
7288
author: Node.js GitHub Bot <github-bot@iojs.org>
7389
committer: Node.js GitHub Bot <github-bot@iojs.org>
7490
body: This is an automated update of OpenSSL to ${{ env.NEW_VERSION }} for ${{ github.ref_name }}.
75-
branch: actions/${{ github.ref_name != github.event.repository.default_branch && format('{0}/', github.ref_name) || '' }}tools-update-openssl
91+
branch: ${{ env.PR_BRANCH }}
7692
labels: dependencies, openssl
7793
title: '${{ env.PR_TITLE_PREFIX }}deps: update OpenSSL to ${{ env.NEW_VERSION }}'

0 commit comments

Comments
 (0)