Skip to content

Commit d13c654

Browse files
committed
Fetch the correct history in the cherryPick.yml workflow
1 parent a6a37fc commit d13c654

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

.github/workflows/cherryPick.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,47 @@ jobs:
4343
with:
4444
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
4545

46-
- name: Get merge commit for CP pull request
46+
- name: Get version bump commit
47+
id: getVersionBumpCommit
48+
run: |
49+
# Find the commit for the version-bump
50+
# This command fetches commits in the last hour on the main branch
51+
git fetch origin main --no-tags --shallow-since="$(( $(date +%s) - 3600 ))"
52+
git switch main
53+
VERSION_BUMP_COMMIT="$(git log --format='%H' --author='OSBotify' --grep 'Update version to ${{ needs.createNewVersion.outputs.NEW_VERSION }}')"
54+
echo "VERSION_BUMP_SHA=$VERSION_BUMP_COMMIT" >> "$GITHUB_OUTPUT"
55+
56+
- name: Get merge commit for pull request to CP
4757
id: getCPMergeCommit
4858
uses: Expensify/App/.github/actions/javascript/getPullRequestDetails@main
4959
with:
5060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5161
USER: ${{ github.actor }}
5262
PULL_REQUEST_NUMBER: ${{ github.event.inputs.PULL_REQUEST_NUMBER }}
5363

54-
- name: Cherry-pick the version-bump to staging
64+
- name: Get previous app version
65+
id: getPreviousVersion
66+
uses: Expensify/App/.github/actions/javascript/getPreviousVersion@main
67+
with:
68+
SEMVER_LEVEL: 'PATCH'
69+
70+
- name: Fetch history of relevant refs
5571
run: |
56-
# Find the commit for the version-bump
57-
# This command fetches commits in the last hour on the main branch
58-
git fetch origin main --no-tags --shallow-since="$(( $(date +%s) - 3600 ))"
59-
git switch main
60-
VERSION_BUMP_COMMIT="$(git log --format='%H' --author='OSBotify' --grep 'Update version to ${{ needs.createNewVersion.outputs.NEW_VERSION }}')"
72+
git fetch origin \
73+
staging \
74+
${{ steps.getVersionBumpCommit.outputs.VERSION_BUMP_SHA }} \
75+
${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} \
76+
--no-tags
77+
--shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
6178
62-
# Cherry-pick it to staging
79+
- name: Cherry-pick the version-bump to staging
80+
run: |
6381
git switch staging
64-
git cherry-pick -S -x --mainline 1 --strategy=recursive -Xtheirs "$VERSION_BUMP_COMMIT"
82+
git cherry-pick -S -x --mainline 1 --strategy=recursive -Xtheirs ${{ steps.getVersionBumpCommit.outputs.VERSION_BUMP_SHA }}
6583
6684
- name: Cherry-pick the merge commit of target PR
6785
id: cherryPick
6886
run: |
69-
if ! git rev-parse --verify ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} 2>/dev/null; then
70-
echo "Merge commit of PR #${{ github.event.inputs.PULL_REQUEST_NUMBER }} (${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}) not found, fetching it now..."
71-
git fetch origin ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} --no-tags --depth=1
72-
fi
73-
7487
echo "Attempting to cherry-pick ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}"
7588
if git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}; then
7689
echo "🎉 No conflicts! CP was a success, PR can be automerged 🎉"

0 commit comments

Comments
 (0)