Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: adjust pr preview environment's recycling time #326

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/pr-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ 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: "144h"
annotations:
sleepmode.kubefree.com/activity-status: '{"LastActivityTime": "${CURRENT_TIME}"}'
spec:
replicas: 1
selector:
Expand All @@ -55,6 +59,10 @@ apiVersion: v1
kind: Service
metadata:
name: goplus-community-pr-${PULL_NUMBER}
labels:
sleepmode.kubefree.com/delete-after: "144h"
annotations:
sleepmode.kubefree.com/activity-status: '{"LastActivityTime":"${CURRENT_TIME}"}'
spec:
selector:
app: goplus-community-pr-${PULL_NUMBER}
Expand All @@ -73,7 +81,7 @@ kubectl -n goplus-pr-review get pods
Preview_URL=http://goplus-community-pr-${PULL_NUMBER}.goplus-pr-review.svc.jfcs-qa1.local
message=$'The PR environment is ready, please check the [PR environment]('${Preview_URL}')

[Attention]: This environment will be automatically cleaned up after 6 hours, please make sure to test it in time. If you have any questions, please contact the author of the PR or the community team.
[Attention]: This environment will be automatically cleaned up after a certain period of time, please make sure to test it in time. If you have any questions, please contact the community team.
'
gh_comment -org=${REPO_OWNER} -repo=${REPO_NAME} -num=${PULL_NUMBER} -p=${Preview_URL} -b "${message}"

Expand Down
Loading