| 
 | 1 | +name: Package Trigger Scheduler  | 
 | 2 | + | 
 | 3 | +on:  | 
 | 4 | +  schedule:  | 
 | 5 | +    - cron:  '31 3 * * 3'  | 
 | 6 | +  workflow_dispatch:  | 
 | 7 | + | 
 | 8 | +jobs:  | 
 | 9 | +  package-trigger-scheduler:  | 
 | 10 | +    runs-on: ubuntu-latest  | 
 | 11 | +    steps:  | 
 | 12 | + | 
 | 13 | +        with:  | 
 | 14 | +          fetch-depth: '0'  | 
 | 15 | + | 
 | 16 | +      - name: Package Trigger Scheduler  | 
 | 17 | +        run: |  | 
 | 18 | +          echo "**** Branches found: ****"  | 
 | 19 | +          git for-each-ref --format='%(refname:short)' refs/remotes  | 
 | 20 | +          echo "**** Pulling the yq docker image ****"  | 
 | 21 | +          docker pull ghcr.io/linuxserver/yq  | 
 | 22 | +          for br in $(git for-each-ref --format='%(refname:short)' refs/remotes)  | 
 | 23 | +          do  | 
 | 24 | +            br=$(echo "$br" | sed 's|origin/||g')  | 
 | 25 | +            echo "**** Evaluating branch ${br} ****"  | 
 | 26 | +            ls_branch=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-nginx/${br}/jenkins-vars.yml \  | 
 | 27 | +              | docker run --rm -i --entrypoint yq ghcr.io/linuxserver/yq -r .ls_branch)  | 
 | 28 | +            if [ "${br}" == "${ls_branch}" ]; then  | 
 | 29 | +              echo "**** Branch ${br} appears to be live; checking workflow. ****"  | 
 | 30 | +              if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-nginx/${br}/.github/workflows/package_trigger.yml > /dev/null 2>&1; then  | 
 | 31 | +                echo "**** Workflow exists. Triggering package trigger workflow for branch ${br}. ****"  | 
 | 32 | +                triggered_branches="${triggered_branches}${br} "  | 
 | 33 | +                curl -iX POST \  | 
 | 34 | +                  -H "Authorization: token ${{ secrets.CR_PAT }}" \  | 
 | 35 | +                  -H "Accept: application/vnd.github.v3+json" \  | 
 | 36 | +                  -d "{\"ref\":\"refs/heads/${br}\"}" \  | 
 | 37 | +                  https://api.github.com/repos/linuxserver/docker-nginx/actions/workflows/package_trigger.yml/dispatches  | 
 | 38 | +                sleep 30  | 
 | 39 | +              else  | 
 | 40 | +                echo "**** Workflow doesn't exist; skipping trigger. ****"  | 
 | 41 | +              fi  | 
 | 42 | +            else  | 
 | 43 | +              echo "**** ${br} appears to be a dev branch; skipping trigger. ****"  | 
 | 44 | +            fi  | 
 | 45 | +          done  | 
 | 46 | +          echo "**** Package check build(s) triggered for branch(es): ${triggered_branches} ****"  | 
 | 47 | +          echo "**** Notifying Discord ****"  | 
 | 48 | +          curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,  | 
 | 49 | +            "description": "**Package Check Build(s) Triggered for nginx** \n**Branch(es):** '"${triggered_branches}"' \n**Build URL:** '"https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-nginx/activity/"' \n"}],  | 
 | 50 | +            "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}  | 
0 commit comments