ls-code-server/.github/workflows/package_trigger.yml
2021-07-12 11:15:07 +02:00

39 lines
2.0 KiB
YAML

name: Package Trigger Main
on:
workflow_dispatch:
jobs:
package-trigger-focal:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.3
- name: Package Trigger
if: github.ref == 'refs/heads/focal'
run: |
if [ -n "${{ secrets.PAUSE_PACKAGE_TRIGGER_CODE_SERVER_FOCAL }}" ]; then
echo "**** Github secret PAUSE_PACKAGE_TRIGGER_CODE_SERVER_FOCAL is set; skipping trigger. ****"
exit 0
fi
if [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-code-server/job/focal/lastBuild/api/json | jq -r '.building') == "true" ]; then
echo "**** There already seems to be an active build on Jenkins; skipping package trigger ****"
exit 0
fi
echo "**** Package trigger running off of focal branch. To disable, set a Github secret named \"PAUSE_PACKAGE_TRIGGER_CODE_SERVER_FOCAL\". ****"
response=$(curl -iX POST \
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-code-server/job/focal/buildWithParameters?PACKAGE_CHECK=true \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
echo "**** Jenkins job queue url: ${response%$'\r'} ****"
echo "**** Sleeping 10 seconds until job starts ****"
sleep 10
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
buildurl="${buildurl%$'\r'}"
echo "**** Jenkins job build url: ${buildurl} ****"
echo "**** Attempting to change the Jenkins job description ****"
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"