Skip to content

Commit f819683

Browse files
Bot Updating Templated Files
1 parent 42a8119 commit f819683

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

Jenkinsfile

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pipeline {
8181
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
8282
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
8383
env.PULL_REQUEST = env.CHANGE_ID
84-
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'
84+
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'
8585
}
8686
sh '''#! /bin/bash
8787
echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" '''
@@ -315,6 +315,7 @@ pipeline {
315315
fi
316316
echo "Starting Stage 2 - Delete old templates"
317317
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"
318+
OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
318319
for i in ${OLD_TEMPLATES}; do
319320
if [[ -f "${i}" ]]; then
320321
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -350,6 +351,10 @@ pipeline {
350351
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
351352
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
352353
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
354+
mkdir -p \
355+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
356+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
357+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
353358
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
354359
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
355360
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -379,6 +384,19 @@ pipeline {
379384
git add docs/images/docker-${CONTAINER_NAME}.md
380385
echo "Updating docs repo"
381386
git commit -m 'Bot Updating Documentation'
387+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
388+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
389+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
390+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
391+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
392+
chmod +x /usr/local/bin/yq
393+
fi
394+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
395+
echo "Updating mkdocs.yml with deprecation info"
396+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {"images/docker-" + env(CONTAINER_NAME) + ".md" : "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
397+
git add mkdocs.yml
398+
fi
399+
git commit -m 'Bot Moving Deprecated Documentation' || :
382400
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
383401
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
384402
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -841,6 +859,7 @@ pipeline {
841859
if [ -n "${SEMVER}" ]; then
842860
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
843861
fi
862+
docker buildx imagetools create -t ${PUSHIMAGE}:39 ghcr.io/linuxserver/jenkins-builder:empty || true
844863
done
845864
'''
846865
}
@@ -872,7 +891,7 @@ pipeline {
872891
fi
873892
done
874893
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
875-
docker buildx imagetools create -t ${MANIFESTIMAGE}:39 ${MANIFESTIMAGE}:amd64-39 ${MANIFESTIMAGE}:arm64v8-39
894+
docker buildx imagetools create -t ${MANIFESTIMAGE}:39 -t ${MANIFESTIMAGE}:amd64-39 -t ${MANIFESTIMAGE}:arm64v8-39 ghcr.io/linuxserver/jenkins-builder:empty || true
876895
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
877896
878897
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG}
@@ -1027,6 +1046,26 @@ EOF
10271046

10281047
}
10291048
}
1049+
stage('Deprecate/Disable Future Builds') {
1050+
when {
1051+
branch "39"
1052+
environment name: 'CHANGE_ID', value: ''
1053+
environment name: 'EXIT_STATUS', value: ''
1054+
}
1055+
steps {
1056+
sh '''#! /bin/bash
1057+
TEMPDIR=$(mktemp -d)
1058+
mkdir -p ${TEMPDIR}/repo
1059+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1060+
cd ${TEMPDIR}/repo/${LS_REPO}
1061+
git checkout -f 39
1062+
git rm Jenkinsfile
1063+
git commit -m 'Disabling future builds'
1064+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git 39
1065+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git 39
1066+
rm -Rf ${TEMPDIR}'''
1067+
}
1068+
}
10301069
}
10311070
/* ######################
10321071
Send status to Discord

0 commit comments

Comments
 (0)