forked from OpenMS/OpenMS
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (52 loc) · 1.67 KB
/
update_nightly.yml
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
name: Update nightly from develop
on:
schedule:
- cron: '7 1 * * *'
workflow_dispatch:
inputs:
force:
type: boolean
description: Forcibly reset Nightly to Develop?
default: false
jobs:
make_nightly:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
- name: Fetch all branches
run: git fetch --all
- name: Determine if develop is ahead of nightly
if: inputs.force != 'true'
id: compare_branches
run: |
if git rev-list --left-right --count origin/develop...origin/nightly | grep -q "0$"; then
if git rev-list --left-right --count origin/develop...origin/nightly | grep -qv "^0"; then
echo "behind=true" >> $GITHUB_OUTPUT
else
echo "behind=false" >> $GITHUB_OUTPUT
fi
else
echo "There are changes to Nightly that are not in develop, we can't automatically update"
echo "To forcibly reset Nightly please have an admin run this action with 'force' enabled"
exit 1
fi
- name: Fast-forward nightly branch if behind develop
if: steps.compare_branches.outputs.behind == 'true'
run: |
git checkout nightly
git merge develop --ff-only
git push origin nightly
env:
GITHUB_TOKEN: ${{ secrets.OPENMS_GITHUB_APP_PRIVATE_KEY }}
- name: Forcibly reset nightly
if: inputs.force
run: |
git checkout nightly
git reset --hard develop
git push origin nightly -f
env:
GITHUB_TOKEN: ${{ secrets.OPENMS_GITHUB_APP_PRIVATE_KEY }}