forked from mesosphere/dcos-docs-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.cron
109 lines (94 loc) · 4.2 KB
/
Jenkinsfile.cron
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env groovy
pipeline {
agent { label "mesos" }
triggers {
cron("0 * * * *")
}
stages {
stage("Maintenance") {
parallel {
stage("Update dev-image") {
environment {
DOCKER = credentials('docker-hub-credentials')
}
steps {
sh '''
docker login -u ${DOCKER_USR} -p ${DOCKER_PSW}
docker pull mesosphere/docs-dev:latest
docker build --cache-from mesosphere/docs-dev:latest -f docker/Dockerfile -t mesosphere/docs-dev:latest .
docker push mesosphere/docs-dev:latest
'''
}
}
stage("Clean up S3-Buckets") {
environment {
AWS_DEFAULT_REGION = "us-west-2"
}
steps {
withCredentials([
[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: "s3-development"],
usernamePassword(credentialsId: "a7ac7f84-64ea-4483-8e66-bb204484e58f", passwordVariable: "GH_PASSWORD", usernameVariable: "GH_USER")
]) {
sh '''#!/bin/bash
set -euxo pipefail
apk add jq --no-cache
buckets=$(docker run -e AWS_ACCESS_KEY_ID -e AWS_DEFAULT_REGION -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN amazon/aws-cli s3api list-buckets | jq '.Buckets | .[].Name' -r | grep "docs-d2iq-com-pr-")
echo $buckets
open_prs=$(docker run curlimages/curl:7.75.0 "https://api.github.com/repos/mesosphere/dcos-docs-site/pulls?state=open" | jq '.[].number')
echo $open_prs
for bucket in $buckets; do
found=false
for pr in $open_prs; do
if [[ $bucket == *"$pr"* ]]; then
found=true
break
fi
done
if [ "$found" = false ] ; then
echo "removing: $bucket"
docker run -e AWS_ACCESS_KEY_ID -e AWS_DEFAULT_REGION -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN amazon/aws-cli s3 rb s3://$bucket --force
fi
done
'''
}
}
}
stage("Sync") {
steps {
withCredentials([string(credentialsId: "d146870f-03b0-4f6a-ab70-1d09757a51fc", variable: "GITHUB_TOKEN")]) {
sshagent(credentials : ['4ff09dce-407b-41d3-847a-9e6609dd91b8']) {
sh '''#!/bin/bash
set -euxo pipefail
##### ENHANCE ON SHALLOW REPO
git config user.name "Docs Bot"
git config user.email "[email protected]"
git remote set-url origin [email protected]:mesosphere/dcos-docs-site.git
git remote set-branches origin '*'
git fetch -v
git checkout -t origin/main || git checkout main || echo "on main"
##### REABSE MAIN ON PORODUCTION
./ci/rebase.sh main production
./ci/rebase.sh beta production
##### CREATE SYNC PRS
apk add curl curl-dev rsync --no-cache
##### Konvoy
./ci/pull-upstream.sh mesosphere/konvoy2 docs/site release-2.0 pages/dkp/konvoy/2.0 production
./ci/pull-upstream.sh mesosphere/konvoy docs/site release-1.8 pages/dkp/konvoy/1.8 production
./ci/pull-upstream.sh mesosphere/konvoy docs/site release-1.7 pages/dkp/konvoy/1.7 production
./ci/pull-upstream.sh mesosphere/konvoy docs/site release-1.6 pages/dkp/konvoy/1.6 production
##### Kommander
./ci/pull-upstream.sh mesosphere/kommander docs/site release-2.0 pages/dkp/kommander/2.0 production
##### Next
mkdir -p pages/dkp/konvoy/2.1
./ci/pull-upstream.sh mesosphere/konvoy2 docs/site main pages/dkp/konvoy/2.1 main
mkdir -p pages/dkp/kommander/2.1
./ci/pull-upstream.sh mesosphere/kommander docs/site main pages/dkp/kommander/2.1 main
'''
}
}
}
}
}
}
}
}