@ -11,15 +11,17 @@ jobs:
- name : External Trigger
- name : External Trigger
if : github.ref == 'refs/heads/master'
if : github.ref == 'refs/heads/master'
env:
SKIP_EXTERNAL_TRIGGER : ${{ vars.SKIP_EXTERNAL_TRIGGER }}
run : |
run : |
printf "# External trigger for docker-ubooquity\n\n" >> $GITHUB_STEP_SUMMARY
printf "# External trigger for docker-ubooquity\n\n" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_UBOOQUITY_MASTER }}" ] ; then
if grep -q "^ubooquity_master" <<< "${SKIP_EXTERNAL_TRIGGER}" ; then
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
echo "> Github secret \`PAUSE_EXTERNAL_TRIGGER_UBOOQUITY_MASTER\` is set ; skipping trigger." >> $GITHUB_STEP_SUMMARY
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`ubooquity_master\` ; skipping trigger." >> $GITHUB_STEP_SUMMARY
exit 0
exit 0
fi
fi
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
echo "> External trigger running off of master branch. To disable this trigger, set a Github secret named \`PAUSE_EXTERNAL_TRIGGER_UBOOQUITY_MASTER\` " >> $GITHUB_STEP_SUMMARY
echo "> External trigger running off of master branch. To disable this trigger, add \`ubooquity_master\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`. " >> $GITHUB_STEP_SUMMARY
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
EXT_RELEASE=$(curl -IsL -w %{url_effective} -o /dev/null http://vaemendis.net/ubooquity/service/download.php | sed 's|.*Ubooquity-\([0-9\.]*\).zip|\1|')
EXT_RELEASE=$(curl -IsL -w %{url_effective} -o /dev/null http://vaemendis.net/ubooquity/service/download.php | sed 's|.*Ubooquity-\([0-9\.]*\).zip|\1|')
echo "Type is \`custom_version_command\`" >> $GITHUB_STEP_SUMMARY
echo "Type is \`custom_version_command\`" >> $GITHUB_STEP_SUMMARY
@ -78,26 +80,38 @@ jobs:
echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
exit 0
exit 0
else
else
printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY
if [[ "${artifacts_found}" == "false" ]]; then
echo "New version \`${EXT_RELEASE}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
response=$(curl -iX POST \
echo "> New version detected, but not all artifacts are published yet; skipping trigger" >> $GITHUB_STEP_SUMMARY
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-ubooquity/job/master/buildWithParameters?PACKAGE_CHECK=false \
FAILURE_REASON="New version ${EXT_RELEASE} for ubooquity tag latest is detected, however not all artifacts are uploaded to upstream release yet. Will try again later."
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
"description": "**Trigger Failed** \n**Reason:** '" ${FAILURE_REASON}"' \n"}],
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
"username": "Github Actions" }' ${{ secrets.DISCORD_WEBHOOK }}
sleep 10
else
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY
buildurl="${buildurl%$'\r'}"
echo "New version \`${EXT_RELEASE}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
if "${artifacts_found}" == "true" ]]; then
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
echo "All artifacts seem to be uploaded." >> $GITHUB_STEP_SUMMARY
curl -iX POST \
fi
"${buildurl}submitDescription" \
response=$(curl -iX POST \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-ubooquity/job/master/buildWithParameters?PACKAGE_CHECK=false \
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
--data-urlencode "Submit=Submit"
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
echo "**** Notifying Discord ****"
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
TRIGGER_REASON="A version change was detected for ubooquity tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
sleep 10
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
"description": "**Build Triggered** \n**Reason:** '" ${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
buildurl="${buildurl%$'\r'}"
"username": "Github Actions" }' ${{ secrets.DISCORD_WEBHOOK }}
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
curl -iX POST \
"${buildurl}submitDescription" \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--data-urlencode "Submit=Submit"
echo "**** Notifying Discord ****"
TRIGGER_REASON="A version change was detected for ubooquity tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
"description": "**Build Triggered** \n**Reason:** '" ${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
"username": "Github Actions" }' ${{ secrets.DISCORD_WEBHOOK }}
fi
fi
fi