|
@@ -2,20 +2,20 @@ name: 4. Build Trio
|
|
|
run-name: Build Trio (${{ github.ref_name }})
|
|
run-name: Build Trio (${{ github.ref_name }})
|
|
|
on:
|
|
on:
|
|
|
workflow_dispatch:
|
|
workflow_dispatch:
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
## Remove the "#" sign from the beginning of the line below to get automated builds on push (code changes in your repository)
|
|
## Remove the "#" sign from the beginning of the line below to get automated builds on push (code changes in your repository)
|
|
|
#push:
|
|
#push:
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
schedule:
|
|
schedule:
|
|
|
- #- cron: '30 04 1 * *' # Runs at 04:30 UTC on the 1st every month
|
|
|
|
|
- - cron: '0 8 * * 3' # Checks for updates at 08:00 UTC every Wednesday
|
|
|
|
|
- - cron: '0 6 1 * *' # Builds the app on the 1st of every month at 06:00 UTC
|
|
|
|
|
|
|
+ - cron: "0 8 * * 3" # Checks for updates at 08:00 UTC every Wednesday
|
|
|
|
|
+ - cron: "0 6 1 * *" # Builds the app on the 1st of every month at 06:00 UTC
|
|
|
|
|
|
|
|
env:
|
|
env:
|
|
|
UPSTREAM_REPO: nightscout/Trio
|
|
UPSTREAM_REPO: nightscout/Trio
|
|
|
UPSTREAM_BRANCH: ${{ github.ref_name }} # branch on upstream repository to sync from (replace with specific branch name if needed)
|
|
UPSTREAM_BRANCH: ${{ github.ref_name }} # branch on upstream repository to sync from (replace with specific branch name if needed)
|
|
|
TARGET_BRANCH: ${{ github.ref_name }} # target branch on fork to be kept in sync, and target branch on upstream to be kept alive (replace with specific branch name if needed)
|
|
TARGET_BRANCH: ${{ github.ref_name }} # target branch on fork to be kept in sync, and target branch on upstream to be kept alive (replace with specific branch name if needed)
|
|
|
- ALIVE_BRANCH: alive
|
|
|
|
|
|
|
+ ALIVE_BRANCH_MAIN: alive-main
|
|
|
|
|
+ ALIVE_BRANCH_DEV: alive-dev
|
|
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
|
validate:
|
|
validate:
|
|
@@ -33,151 +33,172 @@ jobs:
|
|
|
contents: write
|
|
contents: write
|
|
|
outputs:
|
|
outputs:
|
|
|
WORKFLOW_PERMISSION: ${{ steps.workflow-permission.outputs.has_permission }}
|
|
WORKFLOW_PERMISSION: ${{ steps.workflow-permission.outputs.has_permission }}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
steps:
|
|
steps:
|
|
|
- - name: Check for workflow permissions
|
|
|
|
|
- id: workflow-permission
|
|
|
|
|
- env:
|
|
|
|
|
- TOKEN_TO_CHECK: ${{ secrets.GH_PAT }}
|
|
|
|
|
- run: |
|
|
|
|
|
- PERMISSIONS=$(curl -sS -f -I -H "Authorization: token ${{ env.TOKEN_TO_CHECK }}" https://api.github.com | grep ^x-oauth-scopes: | cut -d' ' -f2-);
|
|
|
|
|
-
|
|
|
|
|
- if [[ $PERMISSIONS =~ "workflow" || $PERMISSIONS == "" ]]; then
|
|
|
|
|
- echo "GH_PAT holds workflow permissions or is fine-grained PAT."
|
|
|
|
|
- echo "has_permission=true" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
|
|
|
|
|
- else
|
|
|
|
|
- echo "GH_PAT lacks workflow permissions."
|
|
|
|
|
- echo "Automated build features will be skipped!"
|
|
|
|
|
- echo "has_permission=false" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
|
|
|
|
|
- fi
|
|
|
|
|
-
|
|
|
|
|
- - name: Check for alive branch
|
|
|
|
|
- if: steps.workflow-permission.outputs.has_permission == 'true'
|
|
|
|
|
- env:
|
|
|
|
|
- GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
|
- run: |
|
|
|
|
|
- if [[ "$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/branches | jq --raw-output 'any(.name=="alive")')" == "true" ]]; then
|
|
|
|
|
- echo "Branch 'alive' exists."
|
|
|
|
|
- echo "ALIVE_BRANCH_EXISTS=true" >> $GITHUB_ENV # Set ALIVE_BRANCH_EXISTS to true
|
|
|
|
|
- else
|
|
|
|
|
- echo "Branch 'alive' does not exist."
|
|
|
|
|
- echo "ALIVE_BRANCH_EXISTS=false" >> $GITHUB_ENV # Set ALIVE_BRANCH_EXISTS to false
|
|
|
|
|
- fi
|
|
|
|
|
-
|
|
|
|
|
- - name: Create alive branch
|
|
|
|
|
- if: env.ALIVE_BRANCH_EXISTS == 'false'
|
|
|
|
|
- env:
|
|
|
|
|
- GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
|
- run: |
|
|
|
|
|
- # get ref for nightscout/Trio:dev
|
|
|
|
|
- response=$(curl --request GET \
|
|
|
|
|
- --url "https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/git/refs/heads/dev" \
|
|
|
|
|
- --header "Authorization: Bearer $GITHUB_TOKEN" \
|
|
|
|
|
- --silent)
|
|
|
|
|
- echo "API Response: $response"
|
|
|
|
|
- SHA=$(echo "$response" | jq -r '.object.sha')
|
|
|
|
|
- if [ "$SHA" = "null" ]; then
|
|
|
|
|
- echo "Error: Unable to retrieve SHA for the dev branch."
|
|
|
|
|
- exit 1
|
|
|
|
|
- fi
|
|
|
|
|
- echo "SHA of dev branch: $SHA";
|
|
|
|
|
-
|
|
|
|
|
- # Create alive branch based on nightscout/Trio:dev
|
|
|
|
|
- gh api \
|
|
|
|
|
- --method POST \
|
|
|
|
|
- -H "Authorization: token $GITHUB_TOKEN" \
|
|
|
|
|
- -H "Accept: application/vnd.github.v3+json" \
|
|
|
|
|
- /repos/${{ github.repository }}/git/refs \
|
|
|
|
|
- -f ref='refs/heads/alive' \
|
|
|
|
|
- -f sha=$SHA
|
|
|
|
|
-
|
|
|
|
|
|
|
+ - name: Check for workflow permissions
|
|
|
|
|
+ id: workflow-permission
|
|
|
|
|
+ env:
|
|
|
|
|
+ TOKEN_TO_CHECK: ${{ secrets.GH_PAT }}
|
|
|
|
|
+ run: |
|
|
|
|
|
+ PERMISSIONS=$(curl -sS -f -I -H "Authorization: token ${{ env.TOKEN_TO_CHECK }}" https://api.github.com | grep ^x-oauth-scopes: | cut -d' ' -f2-);
|
|
|
|
|
+
|
|
|
|
|
+ if [[ $PERMISSIONS =~ "workflow" || $PERMISSIONS == "" ]]; then
|
|
|
|
|
+ echo "GH_PAT holds workflow permissions or is fine-grained PAT."
|
|
|
|
|
+ echo "has_permission=true" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "GH_PAT lacks workflow permissions."
|
|
|
|
|
+ echo "Automated build features will be skipped!"
|
|
|
|
|
+ echo "has_permission=false" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ - name: Check for alive branches
|
|
|
|
|
+ if: steps.workflow-permission.outputs.has_permission == 'true'
|
|
|
|
|
+ env:
|
|
|
|
|
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
|
+ run: |
|
|
|
|
|
+ if [[ $(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository_owner }}/Trio/branches | jq --raw-output '[.[] | select(.name == "alive-main" or .name == "alive-dev")] | length > 0') == "true" ]]; then
|
|
|
|
|
+ echo "Branches 'alive-main' or 'alive-dev' exist."
|
|
|
|
|
+ echo "ALIVE_BRANCH_EXISTS=true" >> $GITHUB_ENV
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "Branches 'alive-main' and 'alive-dev' do not exist."
|
|
|
|
|
+ echo "ALIVE_BRANCH_EXISTS=false" >> $GITHUB_ENV
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ - name: Create alive branches
|
|
|
|
|
+ if: env.ALIVE_BRANCH_EXISTS == 'false'
|
|
|
|
|
+ env:
|
|
|
|
|
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
|
+ run: |
|
|
|
|
|
+ # Get ref for UPSTREAM_REPO:main
|
|
|
|
|
+ SHA_MAIN=$(curl -sS -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/git/refs/heads/main | jq -r '.object.sha')
|
|
|
|
|
+
|
|
|
|
|
+ # Get ref for UPSTREAM_REPO:dev
|
|
|
|
|
+ SHA_DEV=$(curl -sS -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/git/refs/heads/dev | jq -r '.object.sha')
|
|
|
|
|
+
|
|
|
|
|
+ # Create alive-main branch in Trio fork based on UPSTREAM_REPO:main
|
|
|
|
|
+ gh api \
|
|
|
|
|
+ --method POST \
|
|
|
|
|
+ -H "Authorization: token $GITHUB_TOKEN" \
|
|
|
|
|
+ -H "Accept: application/vnd.github.v3+json" \
|
|
|
|
|
+ /repos/${{ github.repository_owner }}/Trio/git/refs \
|
|
|
|
|
+ -f ref='refs/heads/alive-main' \
|
|
|
|
|
+ -f sha=$SHA_MAIN
|
|
|
|
|
+
|
|
|
|
|
+ # Create alive-dev branch in Trio fork based on UPSTREAM_REPO:dev
|
|
|
|
|
+ gh api \
|
|
|
|
|
+ --method POST \
|
|
|
|
|
+ -H "Authorization: token $GITHUB_TOKEN" \
|
|
|
|
|
+ -H "Accept: application/vnd.github.v3+json" \
|
|
|
|
|
+ /repos/${{ github.repository_owner }}/Trio/git/refs \
|
|
|
|
|
+ -f ref='refs/heads/alive-dev' \
|
|
|
|
|
+ -f sha=$SHA_DEV
|
|
|
|
|
+
|
|
|
# Checks for changes in upstream repository; if changes exist prompts sync for build
|
|
# Checks for changes in upstream repository; if changes exist prompts sync for build
|
|
|
# Performs keepalive to avoid stale fork
|
|
# Performs keepalive to avoid stale fork
|
|
|
check_latest_from_upstream:
|
|
check_latest_from_upstream:
|
|
|
needs: [validate, check_alive_and_permissions]
|
|
needs: [validate, check_alive_and_permissions]
|
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
|
name: Check upstream and keep alive
|
|
name: Check upstream and keep alive
|
|
|
- outputs:
|
|
|
|
|
|
|
+ outputs:
|
|
|
NEW_COMMITS: ${{ steps.sync.outputs.has_new_commits }}
|
|
NEW_COMMITS: ${{ steps.sync.outputs.has_new_commits }}
|
|
|
-
|
|
|
|
|
|
|
+ ABORT_SYNC: ${{ steps.check_branch.outputs.ABORT_SYNC }}
|
|
|
|
|
+
|
|
|
steps:
|
|
steps:
|
|
|
- - name: Checkout target repo
|
|
|
|
|
- if: |
|
|
|
|
|
- needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- (vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
- with:
|
|
|
|
|
- token: ${{ secrets.GH_PAT }}
|
|
|
|
|
- ref: alive
|
|
|
|
|
-
|
|
|
|
|
- - name: Sync upstream changes
|
|
|
|
|
- if: | # do not run the upstream sync action on the upstream repository
|
|
|
|
|
- needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'nightscout'
|
|
|
|
|
- id: sync
|
|
|
|
|
- uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
|
|
|
|
|
- with:
|
|
|
|
|
- target_sync_branch: ${{ env.ALIVE_BRANCH }}
|
|
|
|
|
- shallow_since: 6 months ago
|
|
|
|
|
- target_repo_token: ${{ secrets.GH_PAT }}
|
|
|
|
|
- upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
|
|
|
|
|
- upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
|
|
|
|
|
-
|
|
|
|
|
- # Display a sample message based on the sync output var 'has_new_commits'
|
|
|
|
|
- - name: New commits found
|
|
|
|
|
- if: |
|
|
|
|
|
- needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true'
|
|
|
|
|
- run: echo "New commits were found to sync."
|
|
|
|
|
-
|
|
|
|
|
- - name: No new commits
|
|
|
|
|
- if: |
|
|
|
|
|
- needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false'
|
|
|
|
|
- run: echo "There were no new commits."
|
|
|
|
|
-
|
|
|
|
|
- - name: Show value of 'has_new_commits'
|
|
|
|
|
- if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' && vars.SCHEDULED_SYNC != 'false'
|
|
|
|
|
- run: |
|
|
|
|
|
- echo ${{ steps.sync.outputs.has_new_commits }}
|
|
|
|
|
- echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
|
|
|
|
|
-
|
|
|
|
|
- # Keep repository "alive": add empty commits to ALIVE_BRANCH after "time_elapsed" days of inactivity to avoid inactivation of scheduled workflows
|
|
|
|
|
- - name: Keep alive
|
|
|
|
|
- if: |
|
|
|
|
|
- needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- (vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
|
|
|
|
|
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
|
|
|
|
|
- with:
|
|
|
|
|
- time_elapsed: 20 # Time elapsed from the previous commit to trigger a new automated commit (in days)
|
|
|
|
|
-
|
|
|
|
|
- - name: Show scheduled build configuration message
|
|
|
|
|
- if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION != 'true'
|
|
|
|
|
- run: |
|
|
|
|
|
- echo "### :calendar: Scheduled Sync and Build Disabled :mobile_phone_off:" >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
- echo "You have not yet configured the scheduled sync and build for Trio's browser build." >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
- echo "Synchronizing your fork of <code>Trio</code> with the upstream repository <code>nightscout/Trio</code> will be skipped." >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
- echo "If you want to enable automatic builds and updates for your Trio, please follow the instructions \
|
|
|
|
|
|
|
+ - name: Check if running on main or dev branch
|
|
|
|
|
+ if: |
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ (vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
|
|
|
|
|
+ id: check_branch
|
|
|
|
|
+ run: |
|
|
|
|
|
+ if [ "${GITHUB_REF##*/}" = "main" ]; then
|
|
|
|
|
+ echo "Running on main branch"
|
|
|
|
|
+ echo "ALIVE_BRANCH=${ALIVE_BRANCH_MAIN}" >> $GITHUB_OUTPUT
|
|
|
|
|
+ echo "ABORT_SYNC=false" >> $GITHUB_OUTPUT
|
|
|
|
|
+ elif [ "${GITHUB_REF##*/}" = "dev" ]; then
|
|
|
|
|
+ echo "Running on dev branch"
|
|
|
|
|
+ echo "ALIVE_BRANCH=${ALIVE_BRANCH_DEV}" >> $GITHUB_OUTPUT
|
|
|
|
|
+ echo "ABORT_SYNC=false" >> $GITHUB_OUTPUT
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "Not running on main or dev branch"
|
|
|
|
|
+ echo "ABORT_SYNC=true" >> $GITHUB_OUTPUT
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ - name: Checkout target repo
|
|
|
|
|
+ if: |
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ (vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
|
|
|
|
|
+ uses: actions/checkout@v4
|
|
|
|
|
+ with:
|
|
|
|
|
+ token: ${{ secrets.GH_PAT }}
|
|
|
|
|
+ ref: ${{ steps.check_branch.outputs.ALIVE_BRANCH }}
|
|
|
|
|
+
|
|
|
|
|
+ - name: Sync upstream changes
|
|
|
|
|
+ if: | # do not run the upstream sync action on the upstream repository
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'nightscout' && steps.check_branch.outputs.ABORT_SYNC == 'false'
|
|
|
|
|
+ id: sync
|
|
|
|
|
+ uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
|
|
|
|
|
+ with:
|
|
|
|
|
+ target_sync_branch: ${{ steps.check_branch.outputs.ALIVE_BRANCH }}
|
|
|
|
|
+ shallow_since: 6 months ago
|
|
|
|
|
+ target_repo_token: ${{ secrets.GH_PAT }}
|
|
|
|
|
+ upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
|
|
|
|
|
+ upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
|
|
|
|
|
+
|
|
|
|
|
+ # Display a sample message based on the sync output var 'has_new_commits'
|
|
|
|
|
+ - name: New commits found
|
|
|
|
|
+ if: |
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true'
|
|
|
|
|
+ run: echo "New commits were found to sync."
|
|
|
|
|
+
|
|
|
|
|
+ - name: No new commits
|
|
|
|
|
+ if: |
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false'
|
|
|
|
|
+ run: echo "There were no new commits."
|
|
|
|
|
+
|
|
|
|
|
+ - name: Show value of 'has_new_commits'
|
|
|
|
|
+ if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' && vars.SCHEDULED_SYNC != 'false' && steps.check_branch.outputs.ABORT_SYNC == 'false'
|
|
|
|
|
+ run: |
|
|
|
|
|
+ echo ${{ steps.sync.outputs.has_new_commits }}
|
|
|
|
|
+ echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
|
|
|
|
|
+
|
|
|
|
|
+ # Keep repository "alive": add empty commits to ALIVE_BRANCH after "time_elapsed" days of inactivity to avoid inactivation of scheduled workflows
|
|
|
|
|
+ - name: Keep alive
|
|
|
|
|
+ if: |
|
|
|
|
|
+ needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ (vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
|
|
|
|
|
+ uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
|
|
|
|
|
+ with:
|
|
|
|
|
+ time_elapsed: 20 # Time elapsed from the previous commit to trigger a new automated commit (in days)
|
|
|
|
|
+
|
|
|
|
|
+ - name: Show scheduled build configuration message
|
|
|
|
|
+ if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION != 'true'
|
|
|
|
|
+ run: |
|
|
|
|
|
+ echo "### :calendar: Scheduled Sync and Build Disabled :mobile_phone_off:" >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
+ echo "You have not yet configured the scheduled sync and build for Trio's browser build." >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
+ echo "Synchronizing your fork of <code>Trio</code> with the upstream repository <code>nightscout/Trio</code> will be skipped." >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
+ echo "If you want to enable automatic builds and updates for your Trio, please follow the instructions \
|
|
|
under the following path <code>Trio/fastlane/testflight.md</code>." >> $GITHUB_STEP_SUMMARY
|
|
under the following path <code>Trio/fastlane/testflight.md</code>." >> $GITHUB_STEP_SUMMARY
|
|
|
-
|
|
|
|
|
|
|
|
|
|
# Builds Trio
|
|
# Builds Trio
|
|
|
build:
|
|
build:
|
|
|
name: Build
|
|
name: Build
|
|
|
needs: [validate, check_alive_and_permissions, check_latest_from_upstream]
|
|
needs: [validate, check_alive_and_permissions, check_latest_from_upstream]
|
|
|
- runs-on: macos-13
|
|
|
|
|
|
|
+ runs-on: macos-14
|
|
|
permissions:
|
|
permissions:
|
|
|
contents: write
|
|
contents: write
|
|
|
- if: | # 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
|
|
|
|
|
- github.event_name == 'workflow_dispatch' ||
|
|
|
|
|
- (needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
- (vars.SCHEDULED_BUILD != 'false' && github.event.schedule == '0 6 1 * *') ||
|
|
|
|
|
- (vars.SCHEDULED_SYNC != 'false' && needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true' )
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ if:
|
|
|
|
|
+ | # 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
|
|
|
|
|
+ github.event_name == 'workflow_dispatch' ||
|
|
|
|
|
+ (needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
|
|
+ (vars.SCHEDULED_BUILD != 'false' && github.event.schedule == '0 6 1 * *') ||
|
|
|
|
|
+ (vars.SCHEDULED_SYNC != 'false' && needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true' )
|
|
|
|
|
+ )
|
|
|
steps:
|
|
steps:
|
|
|
- # Uncomment to manually select Xcode version if needed
|
|
|
|
|
- #- name: Select Xcode version
|
|
|
|
|
- # run: "sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer"
|
|
|
|
|
|
|
+ - name: Select Xcode version
|
|
|
|
|
+ run: "sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer"
|
|
|
|
|
|
|
|
- name: Checkout Repo for syncing
|
|
- name: Checkout Repo for syncing
|
|
|
if: |
|
|
if: |
|
|
@@ -186,12 +207,12 @@ jobs:
|
|
|
uses: actions/checkout@v4
|
|
uses: actions/checkout@v4
|
|
|
with:
|
|
with:
|
|
|
token: ${{ secrets.GH_PAT }}
|
|
token: ${{ secrets.GH_PAT }}
|
|
|
- ref: ${{ env.TARGET_BRANCH }}
|
|
|
|
|
-
|
|
|
|
|
|
|
+ ref: ${{ env.TARGET_BRANCH }}
|
|
|
|
|
+
|
|
|
- name: Sync upstream changes
|
|
- name: Sync upstream changes
|
|
|
if: | # do not run the upstream sync action on the upstream repository
|
|
if: | # do not run the upstream sync action on the upstream repository
|
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
- vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'nightscout'
|
|
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'nightscout' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
|
|
|
id: sync
|
|
id: sync
|
|
|
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
|
|
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
|
|
|
with:
|
|
with:
|
|
@@ -200,24 +221,24 @@ jobs:
|
|
|
target_repo_token: ${{ secrets.GH_PAT }}
|
|
target_repo_token: ${{ secrets.GH_PAT }}
|
|
|
upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
|
|
upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
|
|
|
upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
|
|
upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Display a sample message based on the sync output var 'has_new_commits'
|
|
# Display a sample message based on the sync output var 'has_new_commits'
|
|
|
- name: New commits found
|
|
- name: New commits found
|
|
|
if: |
|
|
if: |
|
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
- vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true'
|
|
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
|
|
|
run: echo "New commits were found to sync."
|
|
run: echo "New commits were found to sync."
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
- name: No new commits
|
|
- name: No new commits
|
|
|
if: |
|
|
if: |
|
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
|
|
|
- vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false'
|
|
|
|
|
|
|
+ vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
|
|
|
run: echo "There were no new commits."
|
|
run: echo "There were no new commits."
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
- name: Show value of 'has_new_commits'
|
|
- name: Show value of 'has_new_commits'
|
|
|
if: |
|
|
if: |
|
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true'
|
|
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true'
|
|
|
- && vars.SCHEDULED_SYNC != 'false'
|
|
|
|
|
|
|
+ && vars.SCHEDULED_SYNC != 'false' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
|
|
|
run: |
|
|
run: |
|
|
|
echo ${{ steps.sync.outputs.has_new_commits }}
|
|
echo ${{ steps.sync.outputs.has_new_commits }}
|
|
|
echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
|
|
echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
|
|
@@ -231,12 +252,23 @@ jobs:
|
|
|
|
|
|
|
|
# Patch Fastlane Match to not print tables
|
|
# Patch Fastlane Match to not print tables
|
|
|
- name: Patch Match Tables
|
|
- name: Patch Match Tables
|
|
|
- run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"
|
|
|
|
|
-
|
|
|
|
|
|
|
+ run: |
|
|
|
|
|
+ TABLE_PRINTER_PATH=$(ruby -e 'puts Gem::Specification.find_by_name("fastlane").gem_dir')/match/lib/match/table_printer.rb
|
|
|
|
|
+ if [ -f "$TABLE_PRINTER_PATH" ]; then
|
|
|
|
|
+ sed -i "" "/puts(Terminal::Table.new(params))/d" "$TABLE_PRINTER_PATH"
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "table_printer.rb not found"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
# Install project dependencies
|
|
# Install project dependencies
|
|
|
- - name: Install project dependencies
|
|
|
|
|
|
|
+ - name: Install Project Dependencies
|
|
|
run: bundle install
|
|
run: bundle install
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
|
|
|
|
|
+ - name: Sync clock
|
|
|
|
|
+ run: sudo sntp -sS time.windows.com
|
|
|
|
|
+
|
|
|
# Build signed Trio IPA file
|
|
# Build signed Trio IPA file
|
|
|
- name: Fastlane Build & Archive
|
|
- name: Fastlane Build & Archive
|
|
|
run: bundle exec fastlane build_trio
|
|
run: bundle exec fastlane build_trio
|
|
@@ -247,7 +279,7 @@ jobs:
|
|
|
FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }}
|
|
FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }}
|
|
|
FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }}
|
|
FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }}
|
|
|
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
|
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Upload to TestFlight
|
|
# Upload to TestFlight
|
|
|
- name: Fastlane upload to TestFlight
|
|
- name: Fastlane upload to TestFlight
|
|
|
run: bundle exec fastlane release
|
|
run: bundle exec fastlane release
|