Skip to content

Commit 29a04b5

Browse files
Bot Updating Templated Files
1 parent e155a09 commit 29a04b5

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

Jenkinsfile

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pipeline {
9393
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
9494
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
9595
env.PULL_REQUEST = env.CHANGE_ID
96-
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'
96+
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'
9797
if ( env.SYFT_IMAGE_TAG == null ) {
9898
env.SYFT_IMAGE_TAG = 'latest'
9999
}
@@ -334,6 +334,7 @@ pipeline {
334334
fi
335335
echo "Starting Stage 2 - Delete old templates"
336336
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"
337+
OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
337338
for i in ${OLD_TEMPLATES}; do
338339
if [[ -f "${i}" ]]; then
339340
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -398,6 +399,10 @@ pipeline {
398399
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
399400
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
400401
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
402+
mkdir -p \
403+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
404+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
405+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
401406
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
402407
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
403408
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -427,6 +432,19 @@ pipeline {
427432
git add docs/images/docker-${CONTAINER_NAME}.md
428433
echo "Updating docs repo"
429434
git commit -m 'Bot Updating Documentation'
435+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
436+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
437+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
438+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
439+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
440+
chmod +x /usr/local/bin/yq
441+
fi
442+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
443+
echo "Updating mkdocs.yml with deprecation info"
444+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {"images/docker-" + env(CONTAINER_NAME) + ".md" : "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
445+
git add mkdocs.yml
446+
fi
447+
git commit -m 'Bot Moving Deprecated Documentation' || :
430448
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
431449
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
432450
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -448,6 +466,10 @@ pipeline {
448466
echo "Updating Unraid template"
449467
cd ${TEMPDIR}/unraid/templates/
450468
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
469+
if ! grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
470+
echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list
471+
git add unraid/ignore.list
472+
fi
451473
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
452474
echo "Image is on the ignore list, and already in the deprecation folder."
453475
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
@@ -940,6 +962,7 @@ pipeline {
940962
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
941963
{ if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
942964
fi
965+
docker buildx imagetools create -t ${PUSHIMAGE}:develop ghcr.io/linuxserver/jenkins-builder:empty || true
943966
done
944967
'''
945968
}
@@ -975,8 +998,7 @@ pipeline {
975998
fi
976999
done
9771000
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
978-
docker buildx imagetools create -t ${MANIFESTIMAGE}:develop ${MANIFESTIMAGE}:amd64-develop ${MANIFESTIMAGE}:arm64v8-develop || \
979-
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
1001+
docker buildx imagetools create -t ${MANIFESTIMAGE}:develop -t ${MANIFESTIMAGE}:amd64-develop -t ${MANIFESTIMAGE}:arm64v8-develop ghcr.io/linuxserver/jenkins-builder:empty || true
9801002
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} || \
9811003
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
9821004
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} || \
@@ -1151,6 +1173,26 @@ EOF
11511173

11521174
}
11531175
}
1176+
stage('Deprecate/Disable Future Builds') {
1177+
when {
1178+
branch "develop"
1179+
environment name: 'CHANGE_ID', value: ''
1180+
environment name: 'EXIT_STATUS', value: ''
1181+
}
1182+
steps {
1183+
sh '''#! /bin/bash
1184+
TEMPDIR=$(mktemp -d)
1185+
mkdir -p ${TEMPDIR}/repo
1186+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1187+
cd ${TEMPDIR}/repo/${LS_REPO}
1188+
git checkout -f develop
1189+
git rm Jenkinsfile
1190+
git commit -m 'Disabling future builds'
1191+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop
1192+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop
1193+
rm -Rf ${TEMPDIR}'''
1194+
}
1195+
}
11541196
}
11551197
/* ######################
11561198
Send status to Discord

0 commit comments

Comments
 (0)