hometown-mastodon/.github/workflows/package_trigger.yml

39 lines
1.9 KiB
YAML
Raw Normal View History

2022-11-08 09:05:24 +00:00
name: Package Trigger Main
on:
workflow_dispatch:
jobs:
package-trigger-main:
runs-on: ubuntu-latest
steps:
2022-11-30 04:47:21 +00:00
- uses: actions/checkout@v3.1.0
2022-11-08 09:05:24 +00:00
- name: Package Trigger
if: github.ref == 'refs/heads/main'
run: |
2022-12-03 15:47:01 +00:00
if [ -n "${{ secrets.PAUSE_PACKAGE_TRIGGER_HOMETOWN_MAIN }}" ]; then
echo "**** Github secret PAUSE_PACKAGE_TRIGGER_HOMETOWN_MAIN is set; skipping trigger. ****"
2022-11-08 09:05:24 +00:00
exit 0
fi
2022-12-03 15:47:01 +00:00
if [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-hometown/job/main/lastBuild/api/json | jq -r '.building') == "true" ]; then
2022-11-08 09:05:24 +00:00
echo "**** There already seems to be an active build on Jenkins; skipping package trigger ****"
exit 0
fi
2022-12-03 15:47:01 +00:00
echo "**** Package trigger running off of main branch. To disable, set a Github secret named \"PAUSE_PACKAGE_TRIGGER_HOMETOWN_MAIN\". ****"
2022-11-08 09:05:24 +00:00
response=$(curl -iX POST \
2022-12-03 15:47:01 +00:00
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-hometown/job/main/buildWithParameters?PACKAGE_CHECK=true \
2022-11-08 09:05:24 +00:00
--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"