Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit e26fdca

Browse files
Bot Updating Templated Files
1 parent d814b52 commit e26fdca

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Diff for: Jenkinsfile

+43-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pipeline {
6868
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
6969
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
7070
env.PULL_REQUEST = env.CHANGE_ID
71-
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 ./root/donate.txt'
71+
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'
7272
}
7373
sh '''#! /bin/bash
7474
echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" '''
@@ -306,6 +306,7 @@ pipeline {
306306
fi
307307
echo "Starting Stage 2 - Delete old templates"
308308
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 Dockerfile.armhf"
309+
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)"
309310
for i in ${OLD_TEMPLATES}; do
310311
if [[ -f "${i}" ]]; then
311312
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -341,6 +342,10 @@ pipeline {
341342
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
342343
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
343344
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
345+
mkdir -p \
346+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
347+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
348+
${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
344349
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
345350
cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || :
346351
cd ${TEMPDIR}/repo/${LS_REPO}/
@@ -370,6 +375,19 @@ pipeline {
370375
git add docs/images/docker-${CONTAINER_NAME}.md
371376
echo "Updating docs repo"
372377
git commit -m 'Bot Updating Documentation'
378+
git mv docs/images/docker-${CONTAINER_NAME}.md docs/deprecated_images/docker-${CONTAINER_NAME}.md || :
379+
if ! command -v yq || ! yq --help | grep -q 'mikefarah'; then
380+
YQ_DL_VERSION=$(curl -fsX GET "https://api.github.com/repos/mikefarah/yq/releases/latest" | jq -r '. | .tag_name')
381+
echo "No yq found, retrieving from upstream release version ${YQ_DL_VERSION}"
382+
curl -fo /usr/local/bin/yq -L "https://github.com/mikefarah/yq/releases/download/${YQ_DL_VERSION}/yq_linux_amd64"
383+
chmod +x /usr/local/bin/yq
384+
fi
385+
if ! yq -e '.plugins.[].redirects.redirect_maps.[] | select(. == "deprecated/" + env(CONTAINER_NAME) + ".md")' mkdocs.yml >/dev/null 2>&1; then
386+
echo "Updating mkdocs.yml with deprecation info"
387+
yq -i '(.plugins.[] | select(.redirects)).redirects.redirect_maps |= . + {env(CONTAINER_NAME) + ".md" : "deprecated/" + env(CONTAINER_NAME) + ".md"}' mkdocs.yml
388+
git add mkdocs.yml
389+
fi
390+
git commit -m 'Bot Moving Deprecated Documentation' || :
373391
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase
374392
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \
375393
(MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \
@@ -391,6 +409,10 @@ pipeline {
391409
echo "Updating Unraid template"
392410
cd ${TEMPDIR}/unraid/templates/
393411
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
412+
if ! grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
413+
echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list
414+
git add unraid/ignore.list
415+
fi
394416
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
395417
echo "Image is on the ignore list, marking Unraid template as deprecated"
396418
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
@@ -1002,6 +1024,26 @@ EOF
10021024

10031025
}
10041026
}
1027+
stage('Deprecate/Disable Future Builds') {
1028+
when {
1029+
branch "develop"
1030+
environment name: 'CHANGE_ID', value: ''
1031+
environment name: 'EXIT_STATUS', value: ''
1032+
}
1033+
steps {
1034+
sh '''#! /bin/bash
1035+
TEMPDIR=$(mktemp -d)
1036+
mkdir -p ${TEMPDIR}/repo
1037+
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1038+
cd ${TEMPDIR}/repo/${LS_REPO}
1039+
git checkout -f develop
1040+
git rm Jenkinsfile
1041+
git commit -m 'Disabling future builds'
1042+
git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop
1043+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop
1044+
rm -Rf ${TEMPDIR}'''
1045+
}
1046+
}
10051047
}
10061048
/* ######################
10071049
Send status to Discord

0 commit comments

Comments
 (0)