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

Commit ce02a55

Browse files
Bot Updating Templated Files
1 parent 0d16d5f commit ce02a55

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

Jenkinsfile

+41-36
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 = 'UNIFI_VERSION'
2120
LS_USER = 'linuxserver'
2221
LS_REPO = 'docker-unifi-controller'
@@ -329,12 +328,12 @@ pipeline {
329328
else
330329
echo "false" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER}
331330
fi
332-
mkdir -p ${TEMPDIR}/gitbook
333-
git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/gitbook/docker-documentation
334-
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
335-
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/
336-
cd ${TEMPDIR}/gitbook/docker-documentation/
337-
git add images/docker-${CONTAINER_NAME}.md
331+
mkdir -p ${TEMPDIR}/docs
332+
git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/docs/docker-documentation
333+
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
334+
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/docs/docker-documentation/docs/images/
335+
cd ${TEMPDIR}/docs/docker-documentation
336+
git add docs/images/docker-${CONTAINER_NAME}.md
338337
git commit -m 'Bot Updating Documentation'
339338
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git --all
340339
fi
@@ -425,35 +424,6 @@ pipeline {
425424
"visibility":"public"}' '''
426425
}
427426
}
428-
/* #######################
429-
Scarf.sh package registry
430-
####################### */
431-
// Add package to Scarf.sh and set permissions
432-
stage("Scarf.sh package registry"){
433-
when {
434-
branch "mongoless"
435-
environment name: 'EXIT_STATUS', value: ''
436-
}
437-
steps{
438-
sh '''#! /bin/bash
439-
PACKAGE_UUID=$(curl -X GET -H "Authorization: Bearer ${SCARF_TOKEN}" https://scarf.sh/api/v1/organizations/linuxserver-ci/packages | jq -r '.[] | select(.name=="linuxserver/unifi-controller") | .uuid' || :)
440-
if [ -z "${PACKAGE_UUID}" ]; then
441-
echo "Adding package to Scarf.sh"
442-
curl -sX POST https://scarf.sh/api/v1/organizations/linuxserver-ci/packages \
443-
-H "Authorization: Bearer ${SCARF_TOKEN}" \
444-
-H "Content-Type: application/json" \
445-
-d '{"name":"linuxserver/unifi-controller",\
446-
"shortDescription":"example description",\
447-
"libraryType":"docker",\
448-
"website":"https://github.com/linuxserver/docker-unifi-controller",\
449-
"backendUrl":"https://ghcr.io/linuxserver/unifi-controller",\
450-
"publicUrl":"https://lscr.io/linuxserver/unifi-controller"}' || :
451-
else
452-
echo "Package already exists on Scarf.sh"
453-
fi
454-
'''
455-
}
456-
}
457427
/* ###############
458428
Build Container
459429
############### */
@@ -849,6 +819,41 @@ pipeline {
849819
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
850820
}
851821
}
822+
// Add protection to the release branch
823+
stage('Github-Release-Branch-Protection') {
824+
when {
825+
branch "mongoless"
826+
environment name: 'CHANGE_ID', value: ''
827+
environment name: 'EXIT_STATUS', value: ''
828+
}
829+
steps {
830+
echo "Setting up protection for release branch mongoless"
831+
sh '''#! /bin/bash
832+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X PUT https://api.github.com/repos/${LS_USER}/${LS_REPO}/branches/mongoless/protection \
833+
-d $(jq -c . << EOF
834+
{
835+
"required_status_checks": null,
836+
"enforce_admins": false,
837+
"required_pull_request_reviews": {
838+
"dismiss_stale_reviews": false,
839+
"require_code_owner_reviews": false,
840+
"require_last_push_approval": false,
841+
"required_approving_review_count": 1
842+
},
843+
"restrictions": null,
844+
"required_linear_history": false,
845+
"allow_force_pushes": false,
846+
"allow_deletions": false,
847+
"block_creations": false,
848+
"required_conversation_resolution": true,
849+
"lock_branch": false,
850+
"allow_fork_syncing": false,
851+
"required_signatures": false
852+
}
853+
EOF
854+
) '''
855+
}
856+
}
852857
// Use helper container to sync the current README on master to the dockerhub endpoint
853858
stage('Sync-README') {
854859
when {

0 commit comments

Comments
 (0)