Skip to content

Commit 93aa541

Browse files
Bot Updating Templated Files
1 parent a659d1b commit 93aa541

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

Jenkinsfile

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pipeline {
6565
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
6666
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
6767
env.PULL_REQUEST = env.CHANGE_ID
68-
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 ./.github/workflows/package_trigger.yml'
68+
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'
6969
}
7070
sh '''#! /bin/bash
7171
echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" '''
@@ -296,6 +296,7 @@ pipeline {
296296
fi
297297
echo "Starting Stage 2 - Delete old templates"
298298
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"
299+
OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
299300
for i in ${OLD_TEMPLATES}; do
300301
if [[ -f "${i}" ]]; then
301302
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -331,6 +332,10 @@ pipeline {
331332
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
332333
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
333334
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
335+
mkdir -p \
336+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
337+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
338+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
334339
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
335340
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
336341
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -360,6 +365,19 @@ pipeline {
360365
git add docs/images/docker-${CONTAINER_NAME}.md
361366
echo "Updating docs repo"
362367
git commit -m 'Bot Updating Documentation'
368+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
369+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
370+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
371+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
372+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
373+
chmod +x /usr/local/bin/yq
374+
fi
375+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
376+
echo "Updating mkdocs.yml with deprecation info"
377+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {"images/docker-" + env(CONTAINER_NAME) + ".md" : "deprecated_images/docker-" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
378+
git add mkdocs.yml
379+
fi
380+
git commit -m 'Bot Moving Deprecated Documentation' || :
363381
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
364382
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
365383
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -938,6 +956,26 @@ EOF
938956

939957
}
940958
}
959+
stage('Deprecate/Disable Future Builds') {
960+
when {
961+
branch "38"
962+
environment name: 'CHANGE_ID', value: ''
963+
environment name: 'EXIT_STATUS', value: ''
964+
}
965+
steps {
966+
sh '''#! /bin/bash
967+
TEMPDIR=$(mktemp -d)
968+
mkdir -p ${TEMPDIR}/repo
969+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
970+
cd ${TEMPDIR}/repo/${LS_REPO}
971+
git checkout -f 38
972+
git rm Jenkinsfile
973+
git commit -m 'Disabling future builds'
974+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git 38
975+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git 38
976+
rm -Rf ${TEMPDIR}'''
977+
}
978+
}
941979
}
942980
/* ######################
943981
Send status to Discord

0 commit comments

Comments
 (0)