-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathback-merge-main-to-develop.yaml
More file actions
83 lines (71 loc) · 2.69 KB
/
Copy pathback-merge-main-to-develop.yaml
File metadata and controls
83 lines (71 loc) · 2.69 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Back-merge main into develop
# back-merge-main-to-develop.yaml
#
# Purpose: After CI release-chore commits land on main (sync-packaging-version,
# readme stats, metainfo/debian regeneration, Crowdin), automatically merge
# main back into develop so the two branches never drift apart again.
#
# Trigger model:
# - workflow_run: catches the chore workflows that push via GITHUB_TOKEN.
# GitHub's "on: push" is NOT retriggered for GITHUB_TOKEN-authored pushes,
# so we watch for those workflow runs completing instead.
# - schedule (hourly): catch-all safety net for any drift source not enumerated
# above (e.g. direct pushes from tools or future CI jobs not listed here).
# - push: branches: [main]: covers human pushes promptly; harmless for
# GITHUB_TOKEN-authored pushes (those are silently skipped by GitHub).
# - workflow_dispatch: allows a manual run at any time.
#
# Loop safety: GITHUB_TOKEN-authored pushes do NOT retrigger workflow runs, so
# this job pushing to develop will never kick off another instance of itself.
on:
workflow_run:
workflows:
- "Sync packaging version"
- "Update README stats"
- "Create GitHub Release"
- "Crowdin Sync"
types:
- completed
# Catch-all safety net: runs hourly to catch any drift source not covered
# by the workflow_run triggers above (offset to avoid top-of-hour rush).
schedule:
- cron: '17 * * * *'
workflow_dispatch:
push:
branches:
- main
# Queue runs rather than cancel them, so back-merges land in order.
concurrency:
group: back-merge-develop
cancel-in-progress: false
permissions:
contents: write
jobs:
back-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
# Default GITHUB_TOKEN is fine; its pushes do not retrigger workflows.
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Merge main into develop and push
run: |
git fetch origin main
if git merge --no-edit --no-ff origin/main; then
# Merge succeeded — check whether there is actually anything new to push.
if git diff --quiet origin/develop..HEAD; then
echo "develop already up to date with main — nothing to push."
else
git push origin develop
fi
else
echo "::error::Automatic back-merge of main into develop hit a conflict — resolve manually."
git merge --abort || true
exit 1
fi