Skip to content

Commit 4d1b0e1

Browse files
Bot Updating Templated Files
1 parent b3fae00 commit 4d1b0e1

File tree

3 files changed

+95
-45
lines changed

3 files changed

+95
-45
lines changed

.github/workflows/external_trigger.yml

+39-25
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ jobs:
1111

1212
- name: External Trigger
1313
if: github.ref == 'refs/heads/master'
14+
env:
15+
SKIP_EXTERNAL_TRIGGER: ${{ vars.SKIP_EXTERNAL_TRIGGER }}
1416
run: |
1517
printf "# External trigger for docker-plex\n\n" >> $GITHUB_STEP_SUMMARY
16-
if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_PLEX_MASTER }}" ]; then
18+
if grep -q "^plex_master" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
1719
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
18-
echo "> Github secret \`PAUSE_EXTERNAL_TRIGGER_PLEX_MASTER\` is set; skipping trigger." >> $GITHUB_STEP_SUMMARY
20+
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`plex_master\`; skipping trigger." >> $GITHUB_STEP_SUMMARY
1921
exit 0
2022
fi
2123
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
22-
echo "> External trigger running off of master branch. To disable this trigger, set a Github secret named \`PAUSE_EXTERNAL_TRIGGER_PLEX_MASTER\`" >> $GITHUB_STEP_SUMMARY
24+
echo "> External trigger running off of master branch. To disable this trigger, add \`plex_master\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY
2325
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
2426
EXT_RELEASE=$(curl -s "https://plex.tv/api/downloads/5.json" | jq -r '. | .computer.Linux.version')
2527
echo "Type is \`custom_json\`" >> $GITHUB_STEP_SUMMARY
@@ -78,26 +80,38 @@ jobs:
7880
echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
7981
exit 0
8082
else
81-
printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY
82-
echo "New version \`${EXT_RELEASE}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY
83-
response=$(curl -iX POST \
84-
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-plex/job/master/buildWithParameters?PACKAGE_CHECK=false \
85-
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
86-
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
87-
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
88-
sleep 10
89-
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
90-
buildurl="${buildurl%$'\r'}"
91-
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
92-
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
93-
curl -iX POST \
94-
"${buildurl}submitDescription" \
95-
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
96-
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
97-
--data-urlencode "Submit=Submit"
98-
echo "**** Notifying Discord ****"
99-
TRIGGER_REASON="A version change was detected for plex tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
100-
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
101-
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
102-
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
83+
if [[ "${artifacts_found}" == "false" ]]; then
84+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
85+
echo "> New version detected, but not all artifacts are published yet; skipping trigger" >> $GITHUB_STEP_SUMMARY
86+
FAILURE_REASON="New version ${EXT_RELEASE} for plex tag latest is detected, however not all artifacts are uploaded to upstream release yet. Will try again later."
87+
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
88+
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}],
89+
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
90+
else
91+
printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY
92+
echo "New version \`${EXT_RELEASE}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY
93+
if "${artifacts_found}" == "true" ]]; then
94+
echo "All artifacts seem to be uploaded." >> $GITHUB_STEP_SUMMARY
95+
fi
96+
response=$(curl -iX POST \
97+
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-plex/job/master/buildWithParameters?PACKAGE_CHECK=false \
98+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
99+
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
100+
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
101+
sleep 10
102+
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
103+
buildurl="${buildurl%$'\r'}"
104+
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
105+
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
106+
curl -iX POST \
107+
"${buildurl}submitDescription" \
108+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
109+
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
110+
--data-urlencode "Submit=Submit"
111+
echo "**** Notifying Discord ****"
112+
TRIGGER_REASON="A version change was detected for plex tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
113+
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
114+
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
115+
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
116+
fi
103117
fi

.github/workflows/package_trigger_scheduler.yml

+48-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
fetch-depth: '0'
1515

1616
- name: Package Trigger Scheduler
17+
env:
18+
SKIP_PACKAGE_TRIGGER: ${{ vars.SKIP_PACKAGE_TRIGGER }}
1719
run: |
1820
printf "# Package trigger scheduler for docker-plex\n\n" >> $GITHUB_STEP_SUMMARY
1921
printf "Found the branches:\n\n%s\n" "$(git for-each-ref --format='- %(refname:lstrip=3)' refs/remotes)" >> $GITHUB_STEP_SUMMARY
@@ -24,27 +26,57 @@ jobs:
2426
continue
2527
fi
2628
printf "\n## Evaluating \`%s\`\n\n" ${br} >> $GITHUB_STEP_SUMMARY
27-
ls_branch=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-plex/${br}/jenkins-vars.yml | yq -r '.ls_branch')
28-
if [ "${br}" == "${ls_branch}" ]; then
29+
JENKINS_VARS=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-plex/${br}/jenkins-vars.yml)
30+
if [[ "${br}" == $(yq -r '.ls_branch' <<< "${JENKINS_VARS}") ]]; then
2931
echo "Branch appears to be live; checking workflow." >> $GITHUB_STEP_SUMMARY
30-
if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-plex/${br}/.github/workflows/package_trigger.yml > /dev/null 2>&1; then
31-
echo "Triggering package trigger workflow for branch ${br}" >> $GITHUB_STEP_SUMMARY
32+
if [[ $(yq -r '.skip_package_check' <<< "${JENKINS_VARS}") == "true" ]]; then
33+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
34+
echo "> Skipping branch ${br} due to \`skip_package_check\` being set in \`jenkins-vars.yml\`." >> $GITHUB_STEP_SUMMARY
35+
skipped_branches="${skipped_branches}${br} "
36+
elif grep -q "^plex_${br}" <<< "${SKIP_PACKAGE_TRIGGER}"; then
37+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
38+
echo "> Github organizational variable \`SKIP_PACKAGE_TRIGGER\` contains \`plex_${br}\`; skipping trigger." >> $GITHUB_STEP_SUMMARY
39+
skipped_branches="${skipped_branches}${br} "
40+
elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-plex/job/${br}/lastBuild/api/json | jq -r '.building') == "true" ]; then
41+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
42+
echo "> There already seems to be an active build on Jenkins; skipping package trigger for ${br}" >> $GITHUB_STEP_SUMMARY
43+
skipped_branches="${skipped_branches}${br} "
44+
else
45+
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
46+
echo "> Triggering package trigger for branch ${br}" >> $GITHUB_STEP_SUMMARY
47+
printf "> To disable, add \`plex_%s\` into the Github organizational variable \`SKIP_PACKAGE_TRIGGER\`.\n\n" "${br}" >> $GITHUB_STEP_SUMMARY
3248
triggered_branches="${triggered_branches}${br} "
49+
response=$(curl -iX POST \
50+
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-plex/job/${br}/buildWithParameters?PACKAGE_CHECK=true \
51+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
52+
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
53+
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
54+
sleep 10
55+
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
56+
buildurl="${buildurl%$'\r'}"
57+
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
58+
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
3359
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-plex/actions/workflows/package_trigger.yml/dispatches
38-
sleep 30
39-
else
40-
echo "Skipping branch ${br} due to no package trigger workflow present." >> $GITHUB_STEP_SUMMARY
60+
"${buildurl}submitDescription" \
61+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
62+
--data-urlencode "description=GHA package trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
63+
--data-urlencode "Submit=Submit"
64+
sleep 20
4165
fi
4266
else
4367
echo "Skipping branch ${br} due to being detected as dev branch." >> $GITHUB_STEP_SUMMARY
4468
fi
4569
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 plex** \n**Branch(es):** '"${triggered_branches}"' \n**Build URL:** '"https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-plex/activity/"' \n"}],
50-
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
70+
if [[ -n "${triggered_branches}" ]] || [[ -n "${skipped_branches}" ]]; then
71+
if [[ -n "${triggered_branches}" ]]; then
72+
NOTIFY_BRANCHES="**Triggered:** ${triggered_branches} \n"
73+
fi
74+
if [[ -n "${skipped_branches}" ]]; then
75+
NOTIFY_BRANCHES="${NOTIFY_BRANCHES}**Skipped:** ${skipped_branches} \n"
76+
fi
77+
echo "**** Package check build(s) triggered for branch(es): ${triggered_branches} ****"
78+
echo "**** Notifying Discord ****"
79+
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
80+
"description": "**Package Check Build(s) Triggered for plex** \n'"${NOTIFY_BRANCHES}"'**Build URL:** '"https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-plex/activity/"' \n"}],
81+
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
82+
fi

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ The architectures supported by this image are:
6161

6262
Webui can be found at `<your-ip>:32400/web`
6363

64-
**note**: If there is no value set for the VERSION variable, then no updates will take place.
64+
>[!NOTE]
65+
>If there is no value set for the VERSION variable, then no updates will take place.
6566
66-
**note**: For new users, no updates will take place on the first run of the container as there is no preferences file to read your token from, to update restart the Docker container after logging in through the webui.
67+
>[!NOTE]
68+
>For new users, no updates will take place on the first run of the container as there is no preferences file to read your token from, to update restart the Docker container after logging in through the webui.
6769
6870
Valid settings for VERSION are:-
6971

70-
**info**: YOU CANNOT UPDATE TO A PLEXPASS ONLY (BETA) VERSION IF YOU ARE NOT LOGGED IN WITH A PLEXPASS ACCOUNT.
72+
>[!NOTE]
73+
>YOU CANNOT UPDATE TO A PLEXPASS ONLY (BETA) VERSION IF YOU ARE NOT LOGGED IN WITH A PLEXPASS ACCOUNT.
7174
7275
+ **`docker`**: Let Docker handle the Plex Version, we keep our Dockerhub Endpoint up to date with the latest public builds. This is the same as leaving this setting out of your create command.
7376
+ **`latest`**: will update plex to the latest version available that you are entitled to.
@@ -322,7 +325,8 @@ Below are the instructions for updating containers:
322325

323326
### Image Update Notifications - Diun (Docker Image Update Notifier)
324327

325-
**tip**: We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported.
328+
>[!TIP]
329+
>We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported.
326330

327331
## Building locally
328332

0 commit comments

Comments
 (0)