2020-11-18 15:31:21 +01:00
name : Package Trigger Main
on :
workflow_dispatch :
jobs :
package-trigger-master :
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
- name : Package Trigger
if : github.ref == 'refs/heads/master'
run : |
2024-08-17 22:20:10 +02:00
printf "# Package trigger for docker-code-server\n\n" >> $GITHUB_STEP_SUMMARY
2020-11-18 15:31:21 +01:00
if [ -n "${{ secrets.PAUSE_PACKAGE_TRIGGER_CODE_SERVER_MASTER }}" ]; then
2024-08-17 22:20:10 +02:00
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
echo "> Github secret \`PAUSE_PACKAGE_TRIGGER_CODE_SERVER_MASTER\` is set; skipping trigger." >> $GITHUB_STEP_SUMMARY
2020-11-18 15:31:21 +01:00
exit 0
fi
2020-11-25 04:39:40 +01:00
if [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-code-server/job/master/lastBuild/api/json | jq -r '.building') == "true" ]; then
2024-08-17 22:20:10 +02:00
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
echo "> There already seems to be an active build on Jenkins; skipping package trigger" >> $GITHUB_STEP_SUMMARY
2020-11-25 04:39:40 +01:00
exit 0
fi
2024-08-17 22:20:10 +02:00
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
echo "> Package trigger running off of master branch. To disable, set a Github secret named \`PAUSE_PACKAGE_TRIGGER_CODE_SERVER_MASTER\`" >> $GITHUB_STEP_SUMMARY
2020-11-18 15:31:21 +01:00
response=$(curl -iX POST \
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-code-server/job/master/buildWithParameters?PACKAGE_CHECK=true \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
2024-08-17 22:20:10 +02:00
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
2020-11-19 15:52:01 +01:00
sleep 10
2020-11-18 15:31:21 +01:00
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
buildurl="${buildurl%$'\r'}"
2024-08-17 22:20:10 +02:00
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
2020-11-18 15:31:21 +01:00
curl -iX POST \
"${buildurl}submitDescription" \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
--data-urlencode "description=GHA package trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--data-urlencode "Submit=Submit"