Skip to content

Commit 6b9e1a0

Browse files
authored
Merge pull request #470 from loopandlearn/bb_schedule
Update the GitHub build schedule to every Sunday
2 parents 10f556d + a8a59be commit 6b9e1a0

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

.github/workflows/build_LoopFollow.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
name: 4. Build Loop Follow
2-
run-name: Build Loop Follow (${{ github.ref_name }})
1+
name: 4. Build LoopFollow
2+
run-name: Build LoopFollow (${{ github.ref_name }})
33
on:
44
workflow_dispatch:
5-
6-
## Remove the "#" sign from the beginning of the line below to get automated builds on push (code changes in your repository)
7-
#push:
8-
95
schedule:
10-
# avoid starting an action at times when GitHub resources are impacted
11-
- cron: "17 12 * * 0" # Checks for updates at 12:17 UTC every Sunday
12-
- cron: "17 10 8-14 * 6" # Builds the app on the second Saturday of each month 10:17 UTC
6+
# Check for updates every Sunday
7+
# Later logic builds if there are updates or if it is the 2nd Sunday of the month
8+
- cron: "17 10 * * 0" # Sunday at UTC 10:17
139

1410
env:
1511
UPSTREAM_REPO: loopandlearn/LoopFollow
@@ -19,6 +15,26 @@ env:
1915
ALIVE_BRANCH_DEV: alive-dev
2016

2117
jobs:
18+
19+
# Set a logic flag if this is the second instance of this day-of-week in this month
20+
day_in_month:
21+
runs-on: ubuntu-latest
22+
name: Check day in month
23+
outputs:
24+
IS_SECOND_IN_MONTH: ${{ steps.date-check.outputs.is_second_instance }}
25+
26+
steps:
27+
- id: date-check
28+
name: Check if this is the second time this day-of-week happens this month
29+
run: |
30+
DAY_OF_MONTH=$(date +%-d)
31+
WEEK_OF_MONTH=$(( ($(date +%-d) - 1) / 7 + 1 ))
32+
if [[ $WEEK_OF_MONTH -eq 2 ]]; then
33+
echo "is_second_instance=true" >> "$GITHUB_OUTPUT"
34+
else
35+
echo "is_second_instance=false" >> "$GITHUB_OUTPUT"
36+
fi
37+
2238
# Checks if Distribution certificate is present and valid, optionally nukes and
2339
# creates new certs if the repository variable ENABLE_NUKE_CERTS == 'true'
2440
check_certs:
@@ -190,15 +206,15 @@ jobs:
190206
# Builds LoopFollow
191207
build:
192208
name: Build
193-
needs: [check_certs, check_alive_and_permissions, check_latest_from_upstream]
209+
needs: [check_certs, check_alive_and_permissions, check_latest_from_upstream, day_in_month]
194210
runs-on: macos-15
195211
permissions:
196212
contents: write
197213
if:
198-
| # runs if started manually, or if sync schedule is set and enabled and scheduled on the first Saturday each month, or if sync schedule is set and enabled and new commits were found
214+
| # builds with manual start; if automatic: once a month or when new commits are found
199215
github.event_name == 'workflow_dispatch' ||
200216
(needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
201-
(vars.SCHEDULED_BUILD != 'false' && github.event.schedule == '17 10 8-14 * 6') ||
217+
(vars.SCHEDULED_BUILD != 'false' && needs.day_in_month.outputs.IS_SECOND_IN_MONTH == 'true') ||
202218
(vars.SCHEDULED_SYNC != 'false' && needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true' )
203219
)
204220
steps:

0 commit comments

Comments
 (0)