Skip to content

Commit dcb5de5

Browse files
committed
Github action to sync with Maxima repo
We take care to keep our sync.yml file safe when we sync to the Maxima repo. That will overwrite everything.
1 parent ebba859 commit dcb5de5

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/sync.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# .github/workflows/sync.yml
2+
name: Sync from Upstream
3+
4+
on:
5+
schedule:
6+
- cron: '0 * * * *' # every hour, adjust as needed
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
fetch-depth: 0
20+
21+
- name: Add upstream and sync
22+
run: |
23+
git remote add upstream https://git.code.sf.net/p/maxima/website
24+
git fetch upstream
25+
26+
# Save the workflow file before syncing
27+
cp .github/workflows/sync.yml /tmp/sync.yml
28+
29+
# Sync all branches
30+
git push origin refs/remotes/upstream/*:refs/heads/* --force-with-lease
31+
git push origin --tags --force
32+
33+
# Restore the workflow file to master
34+
git checkout master
35+
git reset --hard upstream/master
36+
mkdir -p .github/workflows
37+
cp /tmp/sync.yml .github/workflows/sync.yml
38+
git add .github/workflows/sync.yml
39+
git commit -m "Restore sync workflow" --allow-empty
40+
git push origin master

0 commit comments

Comments
 (0)