2020-11-18 15:31:21 +01:00
|
|
|
name: External Trigger Scheduler
|
|
|
|
|
|
|
|
on:
|
|
|
|
schedule:
|
2023-04-29 22:17:11 +02:00
|
|
|
- cron: '32 * * * *'
|
2020-11-18 15:31:21 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
external-trigger-scheduler:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-02-24 21:16:35 +01:00
|
|
|
- uses: actions/checkout@v4.1.1
|
2020-11-18 15:31:21 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: '0'
|
2020-12-18 22:52:41 +01:00
|
|
|
|
2020-11-18 15:31:21 +01:00
|
|
|
- name: External Trigger Scheduler
|
|
|
|
run: |
|
2024-08-17 22:20:10 +02:00
|
|
|
printf "# External trigger scheduler for docker-code-server\n\n" >> $GITHUB_STEP_SUMMARY
|
|
|
|
printf "Found the branches:\n\n%s\n" "$(git for-each-ref --format='- %(refname:lstrip=3)' refs/remotes)" >> $GITHUB_STEP_SUMMARY
|
|
|
|
for br in $(git for-each-ref --format='%(refname:lstrip=3)' refs/remotes)
|
2020-11-18 15:31:21 +01:00
|
|
|
do
|
2024-08-17 22:20:10 +02:00
|
|
|
if [[ "${br}" == "HEAD" ]]; then
|
|
|
|
printf "\nSkipping %s.\n" ${br} >> $GITHUB_STEP_SUMMARY
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
printf "\n## Evaluating \`%s\`\n\n" ${br} >> $GITHUB_STEP_SUMMARY
|
2023-04-29 22:17:11 +02:00
|
|
|
ls_jenkins_vars=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-code-server/${br}/jenkins-vars.yml)
|
|
|
|
ls_branch=$(echo "${ls_jenkins_vars}" | yq -r '.ls_branch')
|
|
|
|
ls_trigger=$(echo "${ls_jenkins_vars}" | yq -r '.external_type')
|
|
|
|
if [[ "${br}" == "${ls_branch}" ]] && [[ "${ls_trigger}" != "os" ]]; then
|
2024-08-17 22:20:10 +02:00
|
|
|
echo "Branch appears to be live and trigger is not os; checking workflow." >> $GITHUB_STEP_SUMMARY
|
2020-11-18 15:31:21 +01:00
|
|
|
if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-code-server/${br}/.github/workflows/external_trigger.yml > /dev/null 2>&1; then
|
2024-08-17 22:20:10 +02:00
|
|
|
echo "Triggering external trigger workflow for branch." >> $GITHUB_STEP_SUMMARY
|
2020-11-18 15:31:21 +01:00
|
|
|
curl -iX POST \
|
|
|
|
-H "Authorization: token ${{ secrets.CR_PAT }}" \
|
|
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
|
|
-d "{\"ref\":\"refs/heads/${br}\"}" \
|
|
|
|
https://api.github.com/repos/linuxserver/docker-code-server/actions/workflows/external_trigger.yml/dispatches
|
|
|
|
else
|
2024-08-17 22:20:10 +02:00
|
|
|
echo "Skipping branch due to no external trigger workflow present." >> $GITHUB_STEP_SUMMARY
|
2020-11-18 15:31:21 +01:00
|
|
|
fi
|
|
|
|
else
|
2024-08-17 22:20:10 +02:00
|
|
|
echo "Skipping branch due to being detected as dev branch or having no external version." >> $GITHUB_STEP_SUMMARY
|
2020-11-18 15:31:21 +01:00
|
|
|
fi
|
|
|
|
done
|