Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Commit 577cc0a

Browse files
Bot Updating Templated Files
1 parent e1b1a9a commit 577cc0a

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

Jenkinsfile

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pipeline {
8484
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
8585
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
8686
env.PULL_REQUEST = env.CHANGE_ID
87-
env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/call_issue_pr_tracker.yml ./.github/workflows/call_issues_cron.yml ./.github/workflows/permissions.yml ./.github/workflows/external_trigger.yml'
87+
env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./root/etc/s6-overlay/s6-rc.d/init-deprecate/run ./root/etc/s6-overlay/s6-rc.d/init-deprecate/up ./root/etc/s6-overlay/s6-rc.d/init-deprecate/type ./root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d/init-config-end ./root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d/init-deprecate ./root/etc/s6-overlay/s6-rc.d/user/contents.d/init-deprecate'
8888
}
8989
sh '''#! /bin/bash
9090
echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" '''
@@ -325,6 +325,7 @@ pipeline {
325325
fi
326326
echo "Starting Stage 2 - Delete old templates"
327327
OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md .github/ISSUE_TEMPLATE/issue.bug.md .github/ISSUE_TEMPLATE/issue.feature.md .github/workflows/call_invalid_helper.yml .github/workflows/stale.yml .github/workflows/package_trigger.yml"
328+
OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
328329
for i in ${OLD_TEMPLATES}; do
329330
if [[ -f "${i}" ]]; then
330331
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -389,6 +390,10 @@ pipeline {
389390
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
390391
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
391392
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
393+
mkdir -p \
394+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
395+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
396+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
392397
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
393398
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
394399
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -418,6 +423,19 @@ pipeline {
418423
git add docs/images/docker-${CONTAINER_NAME}.md
419424
echo "Updating docs repo"
420425
git commit -m 'Bot Updating Documentation'
426+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
427+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
428+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
429+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
430+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
431+
chmod +x /usr/local/bin/yq
432+
fi
433+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
434+
echo "Updating mkdocs.yml with deprecation info"
435+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {"images/docker-" + env(CONTAINER_NAME) + ".md" : "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
436+
git add mkdocs.yml
437+
fi
438+
git commit -m 'Bot Moving Deprecated Documentation' || :
421439
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
422440
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
423441
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -439,6 +457,10 @@ pipeline {
439457
echo "Updating Unraid template"
440458
cd ${TEMPDIR}/unraid/templates/
441459
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
460+
if ! grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
461+
echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list
462+
git add unraid/ignore.list
463+
fi
442464
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
443465
echo "Image is on the ignore list, and already in the deprecation folder."
444466
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
@@ -917,6 +939,7 @@ pipeline {
917939
if [ -n "${SEMVER}" ]; then
918940
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
919941
fi
942+
docker buildx imagetools create -t ${PUSHIMAGE}:latest ghcr.io/linuxserver/jenkins-builder:empty || true
920943
done
921944
'''
922945
}
@@ -948,7 +971,7 @@ pipeline {
948971
fi
949972
done
950973
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
951-
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm64v8-latest
974+
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest -t ${MANIFESTIMAGE}:amd64-latest -t ${MANIFESTIMAGE}:arm64v8-latest ghcr.io/linuxserver/jenkins-builder:empty || true
952975
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
953976
954977
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG}
@@ -1103,6 +1126,26 @@ EOF
11031126

11041127
}
11051128
}
1129+
stage('Deprecate/Disable Future Builds') {
1130+
when {
1131+
branch "master"
1132+
environment name: 'CHANGE_ID', value: ''
1133+
environment name: 'EXIT_STATUS', value: ''
1134+
}
1135+
steps {
1136+
sh '''#! /bin/bash
1137+
TEMPDIR=$(mktemp -d)
1138+
mkdir -p ${TEMPDIR}/repo
1139+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1140+
cd ${TEMPDIR}/repo/${LS_REPO}
1141+
git checkout -f master
1142+
git rm Jenkinsfile
1143+
git commit -m 'Disabling future builds'
1144+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master
1145+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master
1146+
rm -Rf ${TEMPDIR}'''
1147+
}
1148+
}
11061149
}
11071150
/* ######################
11081151
Send status to Discord

0 commit comments

Comments
 (0)