Skip to content

Commit 96b7bda

Browse files
authored
Create agent_checkout_rebase_action.yml (#3027)
Signed-off-by: Nishant Sethunath <nsethunath+@salesforce.com>
1 parent fe4b257 commit 96b7bda

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# .github/workflows/rebase-express-payments.yml
2+
3+
name: 'Auto Rebase adyenExpressPaymentsDreamForceTestAlertBranch'
4+
5+
# This action will trigger on every push to the develop branch.
6+
on:
7+
push:
8+
branches:
9+
- develop
10+
workflow_dispatch:
11+
12+
jobs:
13+
rebase:
14+
name: Rebase adyenExpressPaymentsDreamForceTestAlertBranch on develop
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# Step 1: Check out the repository's code.
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Fetches all history for all branches and tags
23+
24+
# Step 2: Set up the Node.js environment to use npm and npx.
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '22' # Or your project's specific Node.js version
29+
cache: 'npm' # Caches npm dependencies for faster runs
30+
31+
# Step 3: Configure Git with a user name and email.
32+
- name: Set up Git
33+
run: |
34+
git config --global user.name 'GitHub Actions'
35+
git config --global user.email 'actions@github.com'
36+
37+
# Step 4: Switch to the adyenExpressPaymentsDreamForceTestAlertBranch branch.
38+
- name: Switch to adyenExpressPaymentsDreamForceTestAlertBranch branch
39+
run: git checkout adyenExpressPaymentsDreamForceTestAlertBranch
40+
41+
# Step 5: Delete all package-lock.json files before the rebase.
42+
- name: Delete package-lock.json files
43+
run: |
44+
find . -name "package-lock.json" -type f -delete
45+
# We must commit this change so the rebase can proceed cleanly.
46+
# The 'if' statement prevents an error if no lock files were found.
47+
if [[ -n $(git status -s) ]]; then
48+
git add .
49+
git commit -m "chore: remove package-lock.json files before rebase"
50+
else
51+
echo "No package-lock.json files found to delete."
52+
fi
53+
54+
# Step 6: Attempt to rebase the branch. The job will fail if this step fails.
55+
- name: Rebase adyenExpressPaymentsDreamForceTestAlertBranch with develop
56+
run: |
57+
if ! git rebase origin/develop; then
58+
echo "Rebase failed due to conflicts. Aborting."
59+
git rebase --abort
60+
exit 1
61+
fi
62+
63+
# Step 7: Install dependencies after a successful rebase.
64+
# The '--yes' flag for lerna is crucial for non-interactive environments.
65+
- name: Install Dependencies
66+
run: npx lerna clean --yes && npm i
67+
68+
# Step 8: Push the changes only if all previous steps were successful.
69+
- name: Push Changes
70+
run: git push origin adyenExpressPaymentsDreamForceTestAlertBranch --force-with-lease
71+
72+
# Step 9: This notification step will run if any of the above steps fail.
73+
- name: Notify on Failure
74+
if: failure()
75+
uses: slackapi/slack-github-action@v1.26.0
76+
with:
77+
# The channel or user ID to send the notification to.
78+
channel-id: '${{ secrets.AGENT_CHECKOUT_ALERT_SLACK_CHANNEL_ID }}'
79+
# A custom message for the Slack notification.
80+
slack-message: "🚨 Automatic rebase of `adyenExpressPaymentsDreamForceTestAlertBranch` failed. Manual intervention is required. Link to failed action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
81+
env:
82+
# You must store your Slack Bot Token as a secret in your repository settings.
83+
SLACK_BOT_TOKEN: '${{ secrets.AGENT_CHECKOUT_SLACK_BOT_TOKEN }}'
84+
# Forcing a re-index

0 commit comments

Comments
 (0)