Skip to content

Commit b7e38b9

Browse files
committed
Rebase to 3.21
1 parent 2a2cb92 commit b7e38b9

19 files changed

Lines changed: 517 additions & 226 deletions

.editorconfig

100755100644
File mode changed.

.github/CONTRIBUTING.md

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Read, and fill the Pull Request template
77
* If this is a fix for a typo (in code, documentation, or the README) please file an issue and let us sort it out. We do not need a PR
88
* If the PR is addressing an existing issue include, closes #\<issue number>, in the body of the PR commit message
9-
* If you want to discuss changes, you can also bring it up in [#dev-talk](https://discordapp.com/channels/354974912613449730/757585807061155840) in our [Discord server](https://discord.gg/YWrKVTn)
9+
* If you want to discuss changes, you can also bring it up in [#dev-talk](https://discordapp.com/channels/354974912613449730/757585807061155840) in our [Discord server](https://linuxserver.io/discord)
1010

1111
## Common files
1212

@@ -105,10 +105,10 @@ docker build \
105105
-t linuxserver/medusa:latest .
106106
```
107107

108-
The ARM variants can be built on x86_64 hardware using `multiarch/qemu-user-static`
108+
The ARM variants can be built on x86_64 hardware and vice versa using `lscr.io/linuxserver/qemu-static`
109109

110110
```bash
111-
docker run --rm --privileged multiarch/qemu-user-static:register --reset
111+
docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset
112112
```
113113

114114
Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64`.

.github/FUNDING.yml

100755100644
File mode changed.

.github/ISSUE_TEMPLATE/config.yml

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Discord chat support
4-
url: https://discord.gg/YWrKVTn
4+
url: https://linuxserver.io/discord
55
about: Realtime support / chat with the community and the team.
66

77
- name: Discourse discussion forum

.github/ISSUE_TEMPLATE/issue.bug.yml

100755100644
File mode changed.

.github/ISSUE_TEMPLATE/issue.feature.yml

100755100644
File mode changed.

.github/workflows/call_issue_pr_tracker.yml

100755100644
File mode changed.

.github/workflows/call_issues_cron.yml

100755100644
File mode changed.

.github/workflows/external_trigger.yml

100755100644
Lines changed: 88 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,31 @@ 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: |
15-
if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_MEDUSA_MASTER }}" ]; then
16-
echo "**** Github secret PAUSE_EXTERNAL_TRIGGER_MEDUSA_MASTER is set; skipping trigger. ****"
17-
echo "Github secret \`PAUSE_EXTERNAL_TRIGGER_MEDUSA_MASTER\` is set; skipping trigger." >> $GITHUB_STEP_SUMMARY
17+
printf "# External trigger for docker-medusa\n\n" >> $GITHUB_STEP_SUMMARY
18+
if grep -q "^medusa_master_" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
19+
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
20+
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`medusa_master_\`; will skip trigger if version matches." >> $GITHUB_STEP_SUMMARY
21+
elif grep -q "^medusa_master" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
22+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
23+
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`medusa_master\`; skipping trigger." >> $GITHUB_STEP_SUMMARY
1824
exit 0
1925
fi
20-
echo "**** External trigger running off of master branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_MEDUSA_MASTER\". ****"
21-
echo "External trigger running off of master branch. To disable this trigger, set a Github secret named \`PAUSE_EXTERNAL_TRIGGER_MEDUSA_MASTER\`" >> $GITHUB_STEP_SUMMARY
22-
echo "**** Retrieving external version ****"
26+
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
27+
echo "> External trigger running off of master branch. To disable this trigger, add \`medusa_master\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY
28+
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
2329
EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/pymedusa/Medusa/releases/latest" | jq -r '. | .tag_name')
30+
echo "Type is \`github_stable\`" >> $GITHUB_STEP_SUMMARY
31+
if grep -q "^medusa_master_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
32+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
33+
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` matches current external release; skipping trigger." >> $GITHUB_STEP_SUMMARY
34+
exit 0
35+
fi
2436
if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then
25-
echo "**** Can't retrieve external version, exiting ****"
37+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
38+
echo "> Can't retrieve external version, exiting" >> $GITHUB_STEP_SUMMARY
2639
FAILURE_REASON="Can't retrieve external version for medusa branch master"
2740
GHA_TRIGGER_URL="https://github.com/linuxserver/docker-medusa/actions/runs/${{ github.run_id }}"
2841
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680,
@@ -31,24 +44,42 @@ jobs:
3144
exit 1
3245
fi
3346
EXT_RELEASE=$(echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g')
34-
echo "**** External version: ${EXT_RELEASE} ****"
35-
echo "External version: ${EXT_RELEASE}" >> $GITHUB_STEP_SUMMARY
36-
echo "**** Retrieving last pushed version ****"
47+
echo "External version: \`${EXT_RELEASE}\`" >> $GITHUB_STEP_SUMMARY
48+
echo "Retrieving last pushed version" >> $GITHUB_STEP_SUMMARY
3749
image="linuxserver/medusa"
3850
tag="latest"
3951
token=$(curl -sX GET \
4052
"https://ghcr.io/token?scope=repository%3Alinuxserver%2Fmedusa%3Apull" \
4153
| jq -r '.token')
42-
multidigest=$(curl -s \
43-
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
44-
--header "Authorization: Bearer ${token}" \
45-
"https://ghcr.io/v2/${image}/manifests/${tag}" \
46-
| jq -r 'first(.manifests[].digest)')
47-
digest=$(curl -s \
54+
multidigest=$(curl -s \
55+
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
56+
--header "Accept: application/vnd.oci.image.index.v1+json" \
57+
--header "Authorization: Bearer ${token}" \
58+
"https://ghcr.io/v2/${image}/manifests/${tag}")
59+
if jq -e '.layers // empty' <<< "${multidigest}" >/dev/null 2>&1; then
60+
# If there's a layer element it's a single-arch manifest so just get that digest
61+
digest=$(jq -r '.config.digest' <<< "${multidigest}")
62+
else
63+
# Otherwise it's multi-arch or has manifest annotations
64+
if jq -e '.manifests[]?.annotations // empty' <<< "${multidigest}" >/dev/null 2>&1; then
65+
# Check for manifest annotations and delete if found
66+
multidigest=$(jq 'del(.manifests[] | select(.annotations))' <<< "${multidigest}")
67+
fi
68+
if [[ $(jq '.manifests | length' <<< "${multidigest}") -gt 1 ]]; then
69+
# If there's still more than one digest, it's multi-arch
70+
multidigest=$(jq -r ".manifests[] | select(.platform.architecture == \"amd64\").digest?" <<< "${multidigest}")
71+
else
72+
# Otherwise it's single arch
73+
multidigest=$(jq -r ".manifests[].digest?" <<< "${multidigest}")
74+
fi
75+
if digest=$(curl -s \
4876
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
77+
--header "Accept: application/vnd.oci.image.manifest.v1+json" \
4978
--header "Authorization: Bearer ${token}" \
50-
"https://ghcr.io/v2/${image}/manifests/${multidigest}" \
51-
| jq -r '.config.digest')
79+
"https://ghcr.io/v2/${image}/manifests/${multidigest}"); then
80+
digest=$(jq -r '.config.digest' <<< "${digest}");
81+
fi
82+
fi
5283
image_info=$(curl -sL \
5384
--header "Authorization: Bearer ${token}" \
5485
"https://ghcr.io/v2/${image}/blobs/${digest}")
@@ -60,45 +91,54 @@ jobs:
6091
IMAGE_RELEASE=$(echo ${image_info} | jq -r '.Labels.build_version' | awk '{print $3}')
6192
IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-ls' '{print $1}')
6293
if [ -z "${IMAGE_VERSION}" ]; then
63-
echo "**** Can't retrieve last pushed version, exiting ****"
94+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
95+
echo "Can't retrieve last pushed version, exiting" >> $GITHUB_STEP_SUMMARY
6496
FAILURE_REASON="Can't retrieve last pushed version for medusa tag latest"
6597
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680,
6698
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}],
6799
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
68100
exit 1
69101
fi
70-
echo "**** Last pushed version: ${IMAGE_VERSION} ****"
71-
echo "Last pushed version: ${IMAGE_VERSION}" >> $GITHUB_STEP_SUMMARY
102+
echo "Last pushed version: \`${IMAGE_VERSION}\`" >> $GITHUB_STEP_SUMMARY
72103
if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then
73-
echo "**** Version ${EXT_RELEASE} already pushed, exiting ****"
74-
echo "Version ${EXT_RELEASE} already pushed, exiting" >> $GITHUB_STEP_SUMMARY
104+
echo "Version \`${EXT_RELEASE}\` already pushed, exiting" >> $GITHUB_STEP_SUMMARY
75105
exit 0
76106
elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-medusa/job/master/lastBuild/api/json | jq -r '.building') == "true" ]; then
77-
echo "**** New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting ****"
78-
echo "New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
107+
echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
79108
exit 0
80109
else
81-
echo "**** New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build ****"
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-medusa/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'} ****"
87-
echo "**** Sleeping 10 seconds until job starts ****"
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} ****"
92-
echo "Jenkins job build url: ${buildurl}" >> $GITHUB_STEP_SUMMARY
93-
echo "**** Attempting to change the Jenkins job description ****"
94-
curl -iX POST \
95-
"${buildurl}submitDescription" \
96-
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
97-
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
98-
--data-urlencode "Submit=Submit"
99-
echo "**** Notifying Discord ****"
100-
TRIGGER_REASON="A version change was detected for medusa tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
101-
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
102-
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
103-
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
110+
if [[ "${artifacts_found}" == "false" ]]; then
111+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
112+
echo "> New version detected, but not all artifacts are published yet; skipping trigger" >> $GITHUB_STEP_SUMMARY
113+
FAILURE_REASON="New version ${EXT_RELEASE} for medusa tag latest is detected, however not all artifacts are uploaded to upstream release yet. Will try again later."
114+
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
115+
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}],
116+
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
117+
else
118+
printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY
119+
echo "New version \`${EXT_RELEASE}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY
120+
if [[ "${artifacts_found}" == "true" ]]; then
121+
echo "All artifacts seem to be uploaded." >> $GITHUB_STEP_SUMMARY
122+
fi
123+
response=$(curl -iX POST \
124+
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-medusa/job/master/buildWithParameters?PACKAGE_CHECK=false \
125+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
126+
echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY
127+
echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY
128+
sleep 10
129+
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
130+
buildurl="${buildurl%$'\r'}"
131+
echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY
132+
echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY
133+
curl -iX POST \
134+
"${buildurl}submitDescription" \
135+
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
136+
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
137+
--data-urlencode "Submit=Submit"
138+
echo "**** Notifying Discord ****"
139+
TRIGGER_REASON="A version change was detected for medusa tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
140+
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
141+
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
142+
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
143+
fi
104144
fi

.github/workflows/external_trigger_scheduler.yml

100755100644
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ jobs:
1515

1616
- name: External Trigger Scheduler
1717
run: |
18-
echo "**** Branches found: ****"
19-
git for-each-ref --format='%(refname:short)' refs/remotes
20-
for br in $(git for-each-ref --format='%(refname:short)' refs/remotes)
18+
printf "# External trigger scheduler for docker-medusa\n\n" >> $GITHUB_STEP_SUMMARY
19+
printf "Found the branches:\n\n%s\n" "$(git for-each-ref --format='- %(refname:lstrip=3)' refs/remotes)" >> $GITHUB_STEP_SUMMARY
20+
for br in $(git for-each-ref --format='%(refname:lstrip=3)' refs/remotes)
2121
do
22-
br=$(echo "$br" | sed 's|origin/||g')
23-
echo "**** Evaluating branch ${br} ****"
22+
if [[ "${br}" == "HEAD" ]]; then
23+
printf "\nSkipping %s.\n" ${br} >> $GITHUB_STEP_SUMMARY
24+
continue
25+
fi
26+
printf "\n## Evaluating \`%s\`\n\n" ${br} >> $GITHUB_STEP_SUMMARY
2427
ls_jenkins_vars=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-medusa/${br}/jenkins-vars.yml)
2528
ls_branch=$(echo "${ls_jenkins_vars}" | yq -r '.ls_branch')
2629
ls_trigger=$(echo "${ls_jenkins_vars}" | yq -r '.external_type')
2730
if [[ "${br}" == "${ls_branch}" ]] && [[ "${ls_trigger}" != "os" ]]; then
28-
echo "**** Branch ${br} appears to be live and trigger is not os; checking workflow. ****"
31+
echo "Branch appears to be live and trigger is not os; checking workflow." >> $GITHUB_STEP_SUMMARY
2932
if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-medusa/${br}/.github/workflows/external_trigger.yml > /dev/null 2>&1; then
30-
echo "**** Workflow exists. Triggering external trigger workflow for branch ${br} ****."
31-
echo "Triggering external trigger workflow for branch ${br}" >> $GITHUB_STEP_SUMMARY
33+
echo "Triggering external trigger workflow for branch." >> $GITHUB_STEP_SUMMARY
3234
curl -iX POST \
3335
-H "Authorization: token ${{ secrets.CR_PAT }}" \
3436
-H "Accept: application/vnd.github.v3+json" \
3537
-d "{\"ref\":\"refs/heads/${br}\"}" \
3638
https://api.github.com/repos/linuxserver/docker-medusa/actions/workflows/external_trigger.yml/dispatches
3739
else
38-
echo "**** Workflow doesn't exist; skipping trigger. ****"
39-
echo "Skipping branch ${br} due to no external trigger workflow present." >> $GITHUB_STEP_SUMMARY
40+
echo "Skipping branch due to no external trigger workflow present." >> $GITHUB_STEP_SUMMARY
4041
fi
4142
else
42-
echo "**** ${br} is either a dev branch, or has no external version; skipping trigger. ****"
43-
echo "Skipping branch ${br} due to being detected as dev branch or having no external version." >> $GITHUB_STEP_SUMMARY
43+
echo "Skipping branch due to being detected as dev branch or having no external version." >> $GITHUB_STEP_SUMMARY
4444
fi
4545
done

0 commit comments

Comments
 (0)