Skip to content

Commit 16bf944

Browse files
committed
Adapt build_loop.yml and update.yml to be run in an "actions" branch
to be set as default, and used to trigger scheduled builds of the main branch. Empty commits are added to an "actions" branch only (must be created by the user and set as default) to keep this branch "alive" and allow scheduled workflows to run uninterrupted (max 60 days of inactivity). The empty commits will not be included in the resulting TestFlight builds of main. Removed conditionals regarding LoopKit repository.
1 parent a3c31e3 commit 16bf944

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

.github/workflows/build_loop.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ name: 4. Build Loop
22
run-name: Build Loop
33
on:
44
workflow_dispatch:
5+
workflow_call:
56

67
## Remove the "#" sign from the beginning of the line below to get automated builds on push (code changes in your repository)
78
#push:
89

9-
## Remove the "#" sign from the beginning of the two lines below to get automated builds every month
10-
#schedule:
11-
#- cron: '0 17 1 * *' # Runs at 17:00 UTC on the 1st in every month.
12-
1310
env:
1411
UPSTREAM_REPO: LoopKit/LoopWorkspace
15-
UPSTREAM_BRANCH: main
16-
TARGET_BRANCH: main
12+
UPSTREAM_BRANCH: main # upstream branch to sync from
13+
TARGET_BRANCH: main # branch on fork to build from
1714
SYNC_UPSTREAM: 'true' # set to 'false' or 'true' to disable / enable syncing of fork with upstream repository
1815

1916
jobs:

.github/workflows/update.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
name: 'Auto-update'
22

3+
# Runs only on schedule for the default branch
4+
# TARGET_BRANCH should be set as default
5+
# Syncs the target branch with upstream
6+
# Checks for activity and creates empty commits to TARGET_BRANCH as needed after 'time_elapsed' days of inactivity
7+
# Launches the build workflow if new commits are found.
8+
# The build workflow syncs and builds the main branch and uploads to TestFlight
9+
310
on:
11+
workflow_dispatch:
412
schedule:
513
- cron: '0 7 * * 1,4'
614
# scheduled at 07:00 every Monday and Thursday
715

8-
workflow_dispatch: # click the button on Github repo!
9-
1016
env:
1117
UPSTREAM_REPO: LoopKit/LoopWorkspace
1218
UPSTREAM_BRANCH: main
13-
TARGET_BRANCH: main
19+
TARGET_BRANCH: actions # target branch on fork to be kept "alive" for running scheduled workflows (repo activity required at least every 60 days for scheduled workflows to remain active)
1420

1521
jobs:
1622
check_latest_from_upstream:
@@ -33,7 +39,6 @@ jobs:
3339
# REQUIRED step
3440
# Step 2: run the sync action
3541
- name: Sync upstream changes
36-
if: (github.repository_owner != 'LoopKit')
3742
id: sync
3843
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
3944
with:
@@ -59,16 +64,16 @@ jobs:
5964
echo ${{ steps.sync.outputs.has_new_commits }}
6065
echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
6166
62-
# Keep upstream repository "alive": add empty commits after "time_elapsed" days to avoid inactivation of scheduled workflows
67+
# Keep repository "alive": add empty commits to TARGET_BRANCH after "time_elapsed" days of inactivity to avoid inactivation of scheduled workflows
6368
- name: Keep alive
64-
if: (github.ref == 'refs/heads/main' && github.repository_owner == 'LoopKit')
69+
if: github.ref == 'refs/heads/${{ env.TARGET_BRANCH }}'
6570
uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
6671
with:
6772
time_elapsed: 27 # Time elapsed from the previous commit to trigger a new automated commit (in days)
6873

6974
# Launch build workflow if new commits are found
7075
launch_build_workflow:
71-
if: needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true' && (github.repository_owner != 'LoopKit')
76+
if: needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true'
7277
needs: check_latest_from_upstream
7378
name: Launch build workflow
7479
uses: ./.github/workflows/build_loop.yml

0 commit comments

Comments
 (0)