Skip to content

Commit

Permalink
Merge pull request #326 from CarlJi/ci/fix_script
Browse files Browse the repository at this point in the history
ci: adjust pr preview environment's recycling time
  • Loading branch information
xushiwei authored Apr 6, 2024
2 parents 4525dd6 + 8c3df63 commit bb8246b
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit bb8246b

Please sign in to comment.