Skip to content

Commit 2c55d0a

Browse files
Bot Updating Templated Files
1 parent f505cb9 commit 2c55d0a

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

Jenkinsfile

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pipeline {
1616
GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab')
1717
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
1818
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
19-
SCARF_TOKEN=credentials('scarf_api_key')
2019
BUILD_VERSION_ARG = 'OS'
2120
LS_USER = 'linuxserver'
2221
LS_REPO = 'docker-baseimage-debian'
@@ -327,12 +326,12 @@ pipeline {
327326
else
328327
echo "false" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER}
329328
fi
330-
mkdir -p ${TEMPDIR}/gitbook
331-
git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/gitbook/docker-documentation
332-
if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then
333-
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/
334-
cd ${TEMPDIR}/gitbook/docker-documentation/
335-
git add images/docker-${CONTAINER_NAME}.md
329+
mkdir -p ${TEMPDIR}/docs
330+
git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/docs/docker-documentation
331+
if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then
332+
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/docs/docker-documentation/docs/images/
333+
cd ${TEMPDIR}/docs/docker-documentation
334+
git add docs/images/docker-${CONTAINER_NAME}.md
336335
git commit -m 'Bot Updating Documentation'
337336
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git --all
338337
fi
@@ -400,35 +399,6 @@ pipeline {
400399
"visibility":"public"}' '''
401400
}
402401
}
403-
/* #######################
404-
Scarf.sh package registry
405-
####################### */
406-
// Add package to Scarf.sh and set permissions
407-
stage("Scarf.sh package registry"){
408-
when {
409-
branch "bullseye"
410-
environment name: 'EXIT_STATUS', value: ''
411-
}
412-
steps{
413-
sh '''#! /bin/bash
414-
PACKAGE_UUID=$(curl -X GET -H "Authorization: Bearer ${SCARF_TOKEN}" https://scarf.sh/api/v1/organizations/linuxserver-ci/packages | jq -r '.[] | select(.name=="linuxserver/baseimage-debian") | .uuid' || :)
415-
if [ -z "${PACKAGE_UUID}" ]; then
416-
echo "Adding package to Scarf.sh"
417-
curl -sX POST https://scarf.sh/api/v1/organizations/linuxserver-ci/packages \
418-
-H "Authorization: Bearer ${SCARF_TOKEN}" \
419-
-H "Content-Type: application/json" \
420-
-d '{"name":"linuxserver/baseimage-debian",\
421-
"shortDescription":"example description",\
422-
"libraryType":"docker",\
423-
"website":"https://github.com/linuxserver/docker-baseimage-debian",\
424-
"backendUrl":"https://ghcr.io/linuxserver/baseimage-debian",\
425-
"publicUrl":"https://lscr.io/linuxserver/baseimage-debian"}' || :
426-
else
427-
echo "Package already exists on Scarf.sh"
428-
fi
429-
'''
430-
}
431-
}
432402
/* ###############
433403
Build Container
434404
############### */
@@ -821,6 +791,41 @@ pipeline {
821791
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
822792
}
823793
}
794+
// Add protection to the release branch
795+
stage('Github-Release-Branch-Protection') {
796+
when {
797+
branch "bullseye"
798+
environment name: 'CHANGE_ID', value: ''
799+
environment name: 'EXIT_STATUS', value: ''
800+
}
801+
steps {
802+
echo "Setting up protection for release branch bullseye"
803+
sh '''#! /bin/bash
804+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X PUT https://api.github.com/repos/${LS_USER}/${LS_REPO}/branches/bullseye/protection \
805+
-d $(jq -c . << EOF
806+
{
807+
"required_status_checks": null,
808+
"enforce_admins": false,
809+
"required_pull_request_reviews": {
810+
"dismiss_stale_reviews": false,
811+
"require_code_owner_reviews": false,
812+
"require_last_push_approval": false,
813+
"required_approving_review_count": 1
814+
},
815+
"restrictions": null,
816+
"required_linear_history": false,
817+
"allow_force_pushes": false,
818+
"allow_deletions": false,
819+
"block_creations": false,
820+
"required_conversation_resolution": true,
821+
"lock_branch": false,
822+
"allow_fork_syncing": false,
823+
"required_signatures": false
824+
}
825+
EOF
826+
) '''
827+
}
828+
}
824829
// Use helper container to sync the current README on master to the dockerhub endpoint
825830
stage('Sync-README') {
826831
when {

0 commit comments

Comments
 (0)