-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,19 +10,14 @@ jobs: | |
deploy_preview_cleanup: | ||
name: Deploy Preview Cleanup | ||
runs-on: ubuntu-latest | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
deployments: write | ||
|
||
steps: | ||
- name: Checkout chart | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: posthog/charts-clickhouse | ||
path: charts-clickhouse | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -34,6 +29,10 @@ jobs: | |
role-to-assume: arn:aws:iam::169684386827:role/github-terraform-infra-role | ||
role-duration-seconds: 3600 | ||
|
||
- name: Login to Amazon ECR | ||
id: aws-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: connect to tailscale | ||
uses: tailscale/github-action@8b804aa882ac3429b804a2a22f9803a2101a0db9 | ||
env: | ||
|
@@ -43,18 +42,26 @@ jobs: | |
authkey: ${{ secrets.TAILSCALE_OAUTH_SECRET }} | ||
args: --advertise-tags tag:github-runner | ||
|
||
- name: Delete preview deployment | ||
- name: Delete hobby deployment | ||
id: cleanup | ||
run: | | ||
aws eks update-kubeconfig --name "posthog-dev" | ||
kubectl config set-cluster arn:aws:eks:us-east-1:169684386827:cluster/posthog-dev --server=https://eks-posthog-dev --tls-server-name 8BD6E1D2FEBDE47C8177E29CAC9E6C61.gr7.us-east-1.eks.amazonaws.com | ||
aws eks update-kubeconfig --name "posthog-dev" | ||
kubectl config set-cluster arn:aws:eks:us-east-1:169684386827:cluster/posthog-dev --server=https://eks-posthog-dev --tls-server-name 8BD6E1D2FEBDE47C8177E29CAC9E6C61.gr7.us-east-1.eks.amazonaws.com | ||
export PR_NUM=${{ github.event.number }} | ||
export BRANCH_NAME=${{ github.head_ref }} | ||
export BRANCH_NAME_HASH=$(echo -n ${{ github.head_ref }} | md5sum | cut -c 1-8) | ||
export HOSTNAME=pr-$PR_NUM-${BRANCH_NAME_HASH} | ||
export HOSTNAME=${HOSTNAME:0:38} | ||
export HOSTNAME=${HOSTNAME%%-} | ||
export NAMESPACE="hobby" | ||
export REGISTRY_URL=${{ steps.aws-ecr.outputs.registry }}/pr-test | ||
export DOCKER_TAG=${{ github.event.pull_request.head.sha }} | ||
export PR_NUM=${{ github.event.number }} | ||
export BRANCH_NAME=${{ github.head_ref }} | ||
export NAMESPACE=pr-$PR_NUM-${BRANCH_NAME//\//-} | ||
envsubst < posthog/.github/pr-deploy/hobby.yaml.tmpl > posthog/.github/pr-deploy/hobby.yaml | ||
kubectl -n $NAMESPACE delete clickhouseinstallations.clickhouse.altinity.com/posthog || true | ||
kubectl delete namespace $NAMESPACE || true | ||
#Clean and deploy | ||
kubectl -n $NAMESPACE delete -f posthog/.github/pr-deploy/hobby.yaml || true | ||
- name: delete deployment | ||
uses: bobheadxi/[email protected] | ||
|