Skip to content

Trigger Dev Apps Build on Non-Default Branches #76

Trigger Dev Apps Build on Non-Default Branches

Trigger Dev Apps Build on Non-Default Branches #76

name: Trigger Dev Apps Build on Non-Default Branches
on:
schedule:
- cron: "5 0 * * *" # 8:05 pm EDT daily
permissions:
actions: write
contents: read
jobs:
trigger_dev_apps_build:
name: Trigger Daily Dev Apps Build
runs-on: ubuntu-latest
strategy:
matrix:
branch: [release_2.8-1.5]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Check for recent changes
id: check_changes
env:
BRANCH: ${{ matrix.branch }}
run: |
commit_count=$(git rev-list --count --since="24 hours ago" HEAD 2>/dev/null || echo "0")
echo "Commits in last 24 hours: $commit_count"
echo "has_changes=$([ "$commit_count" -gt 0 ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
if [ "$commit_count" -gt 0 ]; then
echo "Found $commit_count commit(s) in the last 24 hours. Will trigger build."
echo "Recent commits:"
git log --since="24 hours ago" --oneline | head -10
else
echo "No commits found in the last 24 hours. Skipping build trigger."
fi
- name: Trigger Dev Apps Build on ${{ matrix.branch }}
if: steps.check_changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ matrix.branch }}
BUILD_TYPE: "full"
run: |
echo "Triggering dev-apps-builder.yaml on branch $BRANCH with build-type $BUILD_TYPE"
response=$(curl -s -w "%{http_code}" -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/dev-apps-builder.yaml/dispatches" \
-d "{\"ref\":\"$BRANCH\",\"inputs\":{\"build-type\":\"$BUILD_TYPE\"}}")
http_code="${response: -3}"
response_body="${response%???}"
if [ "$http_code" = "204" ]; then
echo "Successfully triggered dev-apps-builder.yaml on $BRANCH"
echo "Build type: $BUILD_TYPE"
echo "Timestamp: $(date -u)"
else
echo "Failed to trigger workflow. HTTP code: $http_code"
echo "Response: $response_body"
exit 1
fi