Skip to content

Commit 254179f

Browse files
Bot Updating Templated Files
1 parent 5a75c15 commit 254179f

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

Jenkinsfile

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pipeline {
9696
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
9797
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
9898
env.PULL_REQUEST = env.CHANGE_ID
99-
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 ./root/donate.txt'
99+
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/donate.txt ./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'
100100
if ( env.SYFT_IMAGE_TAG == null ) {
101101
env.SYFT_IMAGE_TAG = 'latest'
102102
}
@@ -344,6 +344,7 @@ pipeline {
344344
fi
345345
echo "Starting Stage 2 - Delete old templates"
346346
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"
347+
OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
347348
for i in ${OLD_TEMPLATES}; do
348349
if [[ -f "${i}" ]]; then
349350
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -408,6 +409,10 @@ pipeline {
408409
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
409410
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
410411
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
412+
mkdir -p \
413+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
414+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
415+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
411416
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
412417
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
413418
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -437,6 +442,19 @@ pipeline {
437442
git add docs/images/docker-${CONTAINER_NAME}.md
438443
echo "Updating docs repo"
439444
git commit -m 'Bot Updating Documentation'
445+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
446+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
447+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
448+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
449+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
450+
chmod +x /usr/local/bin/yq
451+
fi
452+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
453+
echo "Updating mkdocs.yml with deprecation info"
454+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {"images/docker-" + env(CONTAINER_NAME) + ".md" : "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
455+
git add mkdocs.yml
456+
fi
457+
git commit -m 'Bot Moving Deprecated Documentation' || :
440458
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
441459
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
442460
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -458,6 +476,10 @@ pipeline {
458476
echo "Updating Unraid template"
459477
cd ${TEMPDIR}/unraid/templates/
460478
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
479+
if ! grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
480+
echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list
481+
git add unraid/ignore.list
482+
fi
461483
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
462484
echo "Image is on the ignore list, and already in the deprecation folder."
463485
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
@@ -950,6 +972,7 @@ pipeline {
950972
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
951973
{ if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
952974
fi
975+
docker buildx imagetools create -t ${PUSHIMAGE}:latest ghcr.io/linuxserver/jenkins-builder:empty || true
953976
done
954977
'''
955978
}
@@ -985,8 +1008,7 @@ pipeline {
9851008
fi
9861009
done
9871010
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
988-
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm64v8-latest || \
989-
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
1011+
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest -t ${MANIFESTIMAGE}:amd64-latest -t ${MANIFESTIMAGE}:arm64v8-latest ghcr.io/linuxserver/jenkins-builder:empty || true
9901012
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} || \
9911013
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
9921014
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} || \
@@ -1161,6 +1183,26 @@ EOF
11611183

11621184
}
11631185
}
1186+
stage('Deprecate/Disable Future Builds') {
1187+
when {
1188+
branch "main"
1189+
environment name: 'CHANGE_ID', value: ''
1190+
environment name: 'EXIT_STATUS', value: ''
1191+
}
1192+
steps {
1193+
sh '''#! /bin/bash
1194+
TEMPDIR=$(mktemp -d)
1195+
mkdir -p ${TEMPDIR}/repo
1196+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1197+
cd ${TEMPDIR}/repo/${LS_REPO}
1198+
git checkout -f main
1199+
git rm Jenkinsfile
1200+
git commit -m 'Disabling future builds'
1201+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git main
1202+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git main
1203+
rm -Rf ${TEMPDIR}'''
1204+
}
1205+
}
11641206
}
11651207
/* ######################
11661208
Send status to Discord

0 commit comments

Comments
 (0)