Skip to content

Update cron-build.yml #539

Update cron-build.yml

Update cron-build.yml #539

Workflow file for this run

name: 4testing multiarch-cron-build
on:
schedule:
- cron: '0 20 * * *'
push:
branches:
- 'feature/cron-build-oci'
jobs:
select-branches:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: List Branches
id: list-branches
run: |
all_branches=$(git ls-remote -hq | sed -n 's/^[0-9a-f]\{40\}\s\+refs\/heads\//''/p')
matching_branches=$(
{
echo "$all_branches" | grep '^release/v[0-9]'
echo "$all_branches" | grep '^hotfix/v[0-9]'
echo "$all_branches" | grep '^develop$'
} | sed 's/^/"/; s/$/"/'
)
echo "json_output=[${matching_branches//$'\n'/,}]" | sed 's/"/\\"/g' >> $GITHUB_OUTPUT
echo "branches=${matching_branches//$'\n'/ }" | tr -d '[]\"' >> $GITHUB_OUTPUT
- name: Determine Priority Branch
id: priority
run: |
git fetch origin --prune
for branch in ${{ steps.list-branches.outputs.branches }}; do
if git log --since="24 hours ago" origin/$branch --pretty=format:"%h" | grep -q .; then
echo "target_branch=$branch" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "target_branch=" >> $GITHUB_OUTPUT
- name: Check Changes
id: changes
run: |
CHANGED_FILES=$(git log --since="24 hours ago" --name-only --pretty=format: | sort -u)
echo "build_deb=$(echo "${CHANGED_FILES}" | grep -qE '^install/common/|^install/deb/' && echo true || echo false)" >> $GITHUB_OUTPUT
echo "build_rpm=$(echo "${CHANGED_FILES}" | grep -qE '^install/common/|^install/rpm/' && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Dispatch Action main build
run: |
curl \
-X POST \
-u "${{ secrets.USERNAME }}:${{ secrets.TOKEN }}" \
"https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/actions/workflows/75421046/dispatches" \
-H "Accept: application/vnd.github+json" \
--data '{
"ref": "'"${{ github.ref_name }}"'",
"inputs": {
"branches": ${{ steps.list-branches.outputs.json_output }}
}
}'
- name: Dispatch Action build packages
if: ${{ github.event_name == 'schedule' && steps.priority.outputs.target_branch != '' && (steps.changes.outputs.build_deb == 'true' || steps.changes.outputs.build_rpm == 'true') }}
run: |
curl \
-X POST \
-u "${{ secrets.USERNAME}}:${{secrets.TOKEN}}" \
https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/actions/workflows/71256583/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
--data '{
"ref": "'"${{ github.ref_name }}"'",
"inputs": {
"deb_build": "'"${{ steps.changes.outputs.build_deb }}"'",
"rpm_build": "'"${{ steps.changes.outputs.build_rpm }}"'",
"branch-buildtools": "'"${{ steps.priority.outputs.target_branch }}"'",
"branch-client": "'"${{ steps.priority.outputs.target_branch }}"'",
"branch-server": "'"${{ steps.priority.outputs.target_branch }}"'"
}
}'