Skip to content
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d05de3a
Allow either Mobile-Expensify or App CPs
AndrewGable Apr 17, 2025
82544f3
Update getPullRequestDetails
AndrewGable Apr 17, 2025
f28fd71
Rebuild actions, clean up code
AndrewGable Apr 17, 2025
24780f6
Add happy case (no conflicts)
AndrewGable Apr 17, 2025
e81194b
Temporary test
AndrewGable Apr 17, 2025
c07f476
Use Mobile-Expensify-Test-Fork for valid repo as a test
AndrewGable Apr 17, 2025
4ca15d9
Handle http and https
AndrewGable Apr 17, 2025
8dc5625
Update actios
AndrewGable Apr 17, 2025
feb8b44
Revert changes
AndrewGable Apr 17, 2025
0ffce5c
Rebuild gh actions
AndrewGable Apr 17, 2025
77c4a98
Revert all changes to js action
AndrewGable Apr 17, 2025
19edd70
Fix bad delete
AndrewGable Apr 17, 2025
ceb62f1
Use OS Botify for the labeling due to permissions error
AndrewGable Apr 17, 2025
8ed6aff
Save draft state
roryabraham Apr 17, 2025
f863cc3
Fix submodule creation
roryabraham Apr 17, 2025
67369c4
Remove the specific flags causing issues
AndrewGable Apr 18, 2025
902ddc6
Fetch for submodule
AndrewGable Apr 18, 2025
25205fb
Add back the flags
AndrewGable Apr 18, 2025
af82958
Try fetch-depth 0 hack
AndrewGable Apr 18, 2025
81fc64f
Try a different fetching method
AndrewGable Apr 18, 2025
a81628b
Merge branch 'main' into andrew-hybrid-cp
AndrewGable Apr 22, 2025
b5d7c70
Reset much of the code back to main
AndrewGable Apr 22, 2025
256a793
Fix spacing
AndrewGable Apr 22, 2025
b90c45a
Move code around to get PR info first
AndrewGable Apr 22, 2025
12a6570
Add comment for why
AndrewGable Apr 22, 2025
6f8c474
Change how to determine when to fetch-depth:0
AndrewGable Apr 22, 2025
b440734
Adjust git modules to match test
AndrewGable Apr 22, 2025
3b40955
Remove all `Mobile-Expensify-Test-Fork` and use `Mobile-Expensify`
AndrewGable Apr 22, 2025
b90285a
Update from review comments
AndrewGable Apr 23, 2025
112ffcd
Set test repo for CP test
AndrewGable Apr 23, 2025
18592b4
Fix lint
AndrewGable Apr 23, 2025
11ef1c3
Remove testing
AndrewGable Apr 23, 2025
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
69 changes: 48 additions & 21 deletions .github/workflows/cherryPick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,43 @@ jobs:
needs: createNewVersion
runs-on: ubuntu-latest
steps:
- name: Checkout staging branch
# v4
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}
submodules: true

- name: Extract PR information
id: getPRInfo
run: |
echo "REPO_FULL_NAME=$(echo '${{ github.event.inputs.PULL_REQUEST_URL }}' | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/.*|\1|')" >> "$GITHUB_OUTPUT"
echo "REPO_FULL_NAME=$(echo '${{ github.event.inputs.PULL_REQUEST_URL }}' | sed -E 's|https?://github.com/([^/]+/[^/]+)/pull/.*|\1|')" >> "$GITHUB_OUTPUT"
echo "PR_NUMBER=$(echo '${{ github.event.inputs.PULL_REQUEST_URL }}' | sed -E 's|.*/pull/([0-9]+).*|\1|')" >> "$GITHUB_OUTPUT"

- name: Verify repository
run: |
if [ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != "Expensify/App" ]; then
echo "::error::❌ Cherry picks are only supported for the Expensify/App repository. Found: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}"
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != ${{ github.repository }} ]] && [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != "Expensify/Mobile-Expensify" ]]; then
echo "::error::❌ Cherry picks are only supported for the Expensify/App and Expensify/Mobile-Expensify repositories. Found: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}"
exit 1
fi

- name: Set conflict branch name
id: getBranchName
run: echo "CONFLICT_BRANCH_NAME=cherry-pick-staging-${{ steps.getPRInfo.outputs.PR_NUMBER }}-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"

- name: Checkout staging branch with full history if cherry picking Mobile-Expensify
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's create a cleanup issue for this and add it to the project if we haven't already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/Mobile-Expensify' }}
# v4
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}
submodules: true
# Only fetch depth 0 for Mobile-Expensify, because it's a submodule and we need more history to cherry pick successfully
fetch-depth: 0

- name: Checkout staging branch without full history if cherry picking App
if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/App' }}
# v4
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}
submodules: true

# This command is necessary to fetch any branch other than main in the submodule.
# See https://github.com/actions/checkout/issues/1815#issuecomment-2777836442 for further context.
- name: Enable branch-switching in submodules
Expand All @@ -64,15 +76,15 @@ jobs:
with:
SEMVER_LEVEL: "PATCH"

- name: Fetch history of relevant refs
- name: Fetch history of relevant refs if cherry picking an App change
if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/App' }}
run: |
# Temporary hack during transition when -staging suffix is being added to tags
if git ls-remote origin refs/tags/${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }} | grep -q . ; then
git fetch origin main staging --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
else
git fetch origin main staging --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}-staging
fi

cd Mobile-Expensify
# Temporary hack during transition when -staging suffix is being added to tags
if git ls-remote origin refs/tags/${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }} | grep -q . ; then
Expand Down Expand Up @@ -108,13 +120,14 @@ jobs:
fi
echo "VERSION_BUMP_SHA=$VERSION_BUMP_COMMIT" >> "$GITHUB_OUTPUT"

- name: Get merge commit for E/App pull request to CP
- name: Get merge commit for pull request to CP
id: getCPMergeCommit
uses: ./.github/actions/javascript/getPullRequestDetails
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.actor }}
PULL_REQUEST_NUMBER: ${{ steps.getPRInfo.outputs.PR_NUMBER }}
run: |
read -r MERGE_COMMIT_SHA MERGE_ACTOR <<< "$(gh pr view ${{ github.event.inputs.PULL_REQUEST_URL }} --json mergeCommit,author --jq '"\(.mergeCommit.oid) \(.author.login)"')"
echo "MERGE_COMMIT_SHA=$MERGE_COMMIT_SHA" >> "$GITHUB_OUTPUT"
echo "MERGE_ACTOR=$MERGE_ACTOR" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Cherry-pick the Mobile-Expensify version bump to Mobile-Expensify staging
working-directory: Mobile-Expensify
Expand All @@ -135,6 +148,8 @@ jobs:

- name: Cherry-pick the merge commit of target PR
id: cherryPick
# If cherry picking a Mobile-Expensify change, we need to run the cherry pick in the Mobile-Expensify directory
working-directory: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/Mobile-Expensify' && 'Mobile-Expensify' || '.' }}
run: |
echo "Attempting to cherry-pick ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}"
if git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}; then
Expand All @@ -154,6 +169,18 @@ jobs:
git checkout -b ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}
git push --set-upstream origin ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}
else
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" == "Expensify/Mobile-Expensify" ]]; then
# Push Mobile-Expensify changes first
cd Mobile-Expensify
git push origin staging
cd ..

# Update and commit the submodule reference in E/App
git add Mobile-Expensify
git commit -m "Update Mobile-Expensify submodule to include cherry-picked PR #${{ steps.getPRInfo.outputs.PR_NUMBER }}"
fi

# Push E/App changes
git push origin staging
fi

Expand Down Expand Up @@ -212,9 +239,9 @@ jobs:
continue-on-error: true

- name: Label original PR with CP Staging
run: gh pr edit ${{ github.event.inputs.PULL_REQUEST_URL }} --add-label 'CP Staging'
run: gh pr edit ${{ github.event.inputs.PULL_REQUEST_URL }} --add-label 'CP Staging'
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: "Announces a CP failure in the #announce Slack room"
# v3
Expand Down