-
Notifications
You must be signed in to change notification settings - Fork 2
46 lines (38 loc) · 1.37 KB
/
Copy pathsync-branches.yml
File metadata and controls
46 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Sync branches
on:
push:
branches:
- main
permissions:
contents: write # Necesario para que el push funcione
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1️⃣ Clonamos el repo con la deploy key y todo el historial (fetch-depth: 0 es clave)
- name: Checkout main
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
fetch-depth: 0
# 2️⃣ Configuramos identidad del bot
- name: Setup Git
run: |
git config user.name "Staging Sync Bot"
git config user.email "staging-sync-bot@users.noreply.github.com"
# 3️⃣ Sincronizamos staging con main solo si es fast-forward posible
- name: Push to staging
run: |
# Traemos lo último de remoto
git fetch origin
# Si la rama staging existe, la usamos; si no, la creamos desde remoto
git checkout staging || git checkout -b staging origin/staging
# Intentamos fast-forward desde main
if git merge --ff-only origin/main; then
echo "✅ Fast-forward successful. Pushing to staging..."
git push origin staging
else
echo "❌ No fast-forward possible. Manual intervention required."
# Si quieres que simplemente no haga nada, comenta la siguiente línea
exit 1
fi