80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
name: "<reusable> DocSpace cron trigger"
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
organization:
|
|
description: "Organization name"
|
|
required: false
|
|
type: string
|
|
default: 'ONLYOFFICE'
|
|
repository:
|
|
description: "Repo where reusable cron is stored"
|
|
required: false
|
|
type: string
|
|
default: 'DocSpace-buildtools'
|
|
secrets:
|
|
git-user:
|
|
required: true
|
|
description: "User that will trigger job from curl"
|
|
git-token:
|
|
description: "User token"
|
|
required: true
|
|
|
|
jobs:
|
|
|
|
select-branches:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out the code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: 'ONLYOFFICE/DocSpace-buildtools'
|
|
|
|
- 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=""
|
|
|
|
for branch in $all_branches; do
|
|
if [[ $branch =~ ^release/v[0-9]+ || $branch =~ ^hotfix/v[0-9]+ || $branch == "develop" ]]; then
|
|
matching_branches="${matching_branches},\"${branch}\""
|
|
fi
|
|
done
|
|
|
|
matching_branches=${matching_branches#,}
|
|
echo "json_output=[${matching_branches}]" >> $GITHUB_OUTPUT
|
|
|
|
last_branch=$(echo ${matching_branches} | awk -F, '{print $NF}' | sed 's/"//g')
|
|
echo "last_branch=${last_branch}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Dispatch Action
|
|
run: |
|
|
echo "${{ steps.list-branches.outputs.json_output }}"
|
|
|
|
curl \
|
|
-X POST \
|
|
-u "${{ secrets.git-user }}:${{ secrets.git-token }}" \
|
|
"https://api.github.com/repos/${{ inputs.organization }}/${{ inputs.repository }}/dispatches" \
|
|
-H "Accept: application/vnd.github.everest-preview+json" \
|
|
--data '{"event_type": "cron-trigger-action", "client_payload": { "branches": ${{ steps.list-branches.outputs.json_output }}}}'
|
|
|
|
- name: Dispatch package build
|
|
if: github.repository == 'ONLYOFFICE/DocSpace-buildtools'
|
|
run: |
|
|
curl \
|
|
-X POST \
|
|
-u "${{ secrets.git-user }}:${{ secrets.git-token }}" \
|
|
https://api.github.com/repos/ONLYOFFICE/DocSpace/actions/workflows/59268961/dispatches \
|
|
-H "Accept: application/vnd.github.everest-preview+json" \
|
|
--data '{
|
|
"ref": "${{ steps.list-branches.outputs.last_branch }}",
|
|
"inputs": {
|
|
"branch-buildtools": "${{ steps.list-branches.outputs.last_branch }}",
|
|
"branch-client": "${{ steps.list-branches.outputs.last_branch }}",
|
|
"branch-server": "${{ steps.list-branches.outputs.last_branch }}"
|
|
}
|
|
}'
|