Skip to content

Commit

Permalink
Add deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
danielxnj committed Nov 17, 2023
1 parent fd7d306 commit 661655c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/pr-deploy/hobby.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hobby-$HOSTNAME
spec:
replicas: 1
selector:
matchLabels:
app: hobby-$HOSTNAME
template:
metadata:
labels:
app: hobby-$HOSTNAME
spec:
containers:
- name: hobby-$HOSTNAME
image: 169684386827.dkr.ecr.us-east-1.amazonaws.com/hobby-base:latest
imagePullPolicy: Always
securityContext:
privileged: true
ports:
- containerPort: 2375
- containerPort: 80
env:
- name: BRANCH_NAME
value: $BRANCH_NAME

---
apiVersion: v1
kind: Service
metadata:
name: hobby-service-$HOSTNAME
spec:
selector:
app: hobby-$HOSTNAME
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
18 changes: 10 additions & 8 deletions .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@ jobs:
export PR_NUM=${{ github.event.number }}
export BRANCH_NAME=${{ github.head_ref }}
export RELEASE_NAME=posthog
export NAMESPACE=pr-$PR_NUM-${BRANCH_NAME//\//-}
export NAMESPACE=${NAMESPACE:0:38}
export NAMESPACE=${NAMESPACE%%-}
export HOSTNAME=$NAMESPACE
export TAILNET_NAME=hedgehog-kitefin
export HOSTNAME=pr-$PR_NUM-${BRANCH_NAME//\//-}
export HOSTNAME=${HOSTNAME:0:38}
export HOSTNAME=${HOSTNAME%%-}
export NAMESPACE="hobby"
export TAILNET_NAME=${HOSTNAME}-hedgehog-kitefin
export TS_AUTHKEY=${{ secrets.TAILSCALE_SERVICE_AUTHKEY }}
export POSTHOG_WEB_SERVICE_NAME=POSTHOG_WEB
export POSTHOG_WEB_SERVICE_PORT=8000
envsubst < posthog/.github/pr-deploy/tailscale.yaml.tmpl > posthog/.github/pr-deploy/tailscale.yaml
envsubst < posthog/.github/pr-deploy/values.yaml.tmpl > posthog/.github/pr-deploy/values.yaml
envsubst < posthog/.github/pr-deploy/hobby.yaml.tmpl > posthog/.github/pr-deploy/hobby.yaml
echo "url=$NAMESPACE.hedgehog-kitefin.ts.net" >> $GITHUB_OUTPUT
kubectl -n $NAMESPACE apply -f posthog/.github/pr-deploy/tailscale.yaml
kubectl -n $NAMESPACE apply -f posthog/.github/pr-deploy/hobby.yaml
echo "url=$NAMESPACE.${HOSTNAME}-hedgehog-kitefin.ts.net" >> $GITHUB_OUTPUT
# helm upgrade --install \
# -f posthog/.github/pr-deploy/values.yaml \
# --set image.tag=pr-$PR_NUM \
Expand All @@ -90,7 +93,6 @@ jobs:
# || kubectl -n $NAMESPACE exec $POD_NAME -- python manage.py generate_demo_data \
# && kubectl -n $NAMESPACE exec $POD_NAME -- python manage.py shell -c "from posthog.models import Team; t = Team.objects.first(); t.is_demo = False; t.save()"
# kubectl -n $NAMESPACE apply -f posthog/.github/pr-deploy/tailscale.yaml
- name: update deployment status
uses: bobheadxi/deployments@v1
Expand Down

0 comments on commit 661655c

Please sign in to comment.