0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/.github/workflows/pr-cleanup.yml
dependabot[bot] 26c1dac4f1
chore(deps): bump aws-actions/amazon-ecr-login from 1 to 2 (#19558)
Bumps [aws-actions/amazon-ecr-login](https://github.com/aws-actions/amazon-ecr-login) from 1 to 2.
- [Release notes](https://github.com/aws-actions/amazon-ecr-login/releases)
- [Changelog](https://github.com/aws-actions/amazon-ecr-login/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/amazon-ecr-login/compare/v1...v2)

---
updated-dependencies:
- dependency-name: aws-actions/amazon-ecr-login
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-02 15:27:40 +00:00

71 lines
2.7 KiB
YAML

# This workflow cleans up Preview deploys once a pull request is closed
name: PR - Preview Deploy Cleanup
on:
pull_request:
types: [closed]
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
uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
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@v2
- name: connect to tailscale
uses: tailscale/github-action@8b804aa882ac3429b804a2a22f9803a2101a0db9
env:
TS_EXPERIMENT_OAUTH_AUTHKEY: true
with:
version: 1.42.0
authkey: ${{ secrets.TAILSCALE_OAUTH_SECRET }}
args: --advertise-tags tag:github-runner
- 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
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 }}
envsubst < .github/pr-deploy/hobby.yaml.tmpl > .github/pr-deploy/hobby.yaml
#Clean and deploy
kubectl -n $NAMESPACE delete -f .github/pr-deploy/hobby.yaml || true
- name: delete deployment
uses: bobheadxi/deployments@v1.4.0
id: deployment
with:
step: deactivate-env
env: pr-${{ github.head_ref }}
ref: ${{ github.head_ref }}