Skip to content

Commit

Permalink
ci: adjust pr preview environment's recycling time
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlJi committed Apr 2, 2024
1 parent 867de4e commit fb9d528
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/pr-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ EOF
export CONTAINER_IMAGE=aslan-spock-register.qiniu.io/goplus/goplus-community-pr:${PULL_NUMBER}-${PULL_PULL_SHA:0:8}
docker build -t ${CONTAINER_IMAGE} -f ./Dockerfile . --builder="kube" --push

export CURRENT_TIME=$(date "--iso-8601=seconds")

# generate kubernetes yaml with unique flag for PR
cat > community.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: goplus-community-pr-${PULL_NUMBER}
labels:
sleepmode.kubefree.com/delete-after: "6d"
annotations:
sleepmode.kubefree.com/activity-status: {
"LastActivityTime\": "${CURRENT_TIME}"
}
spec:
replicas: 1
selector:
Expand All @@ -55,6 +62,12 @@ apiVersion: v1
kind: Service
metadata:
name: goplus-community-pr-${PULL_NUMBER}
labels:
sleepmode.kubefree.com/delete-after: "6d"
annotations:
sleepmode.kubefree.com/activity-status: {
"LastActivityTime\": "${CURRENT_TIME}"
}
spec:
selector:
app: goplus-community-pr-${PULL_NUMBER}
Expand Down

0 comments on commit fb9d528

Please sign in to comment.