From ec2f6a58edf36e53e010469b2aa5649eedd6489d Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Wed, 13 Nov 2024 23:48:39 +0000 Subject: [PATCH] Added teardown examples stack --- .github/workflows/deploy_examples.yml | 32 +++++----- .../workflows/teardown_examples_pr_stack.yml | 62 +++++++++++++++++++ pnpm-lock.yaml | 14 +++-- 3 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/teardown_examples_pr_stack.yml diff --git a/.github/workflows/deploy_examples.yml b/.github/workflows/deploy_examples.yml index 7ccc0b7e07..7ced0b72ab 100644 --- a/.github/workflows/deploy_examples.yml +++ b/.github/workflows/deploy_examples.yml @@ -1,4 +1,4 @@ -name: Deploy Examples Production +name: Deploy Examples on: push: @@ -7,25 +7,25 @@ on: paths: ['examples/*/**'] concurrency: - group: prod-deploy-group + group: ${{ github.event_name == 'push' && 'prod-deploy-group' || format('examples-pr-{0}', github.event.number) }} jobs: - deploy-linearlite: - name: Deploy Examples Production - environment: Production + deploy-examples: + name: Deploy Examples + environment: ${{ github.event_name == 'push' && 'Production' || 'Pull request' }} runs-on: ubuntu-latest - + env: - DEPLOY_ENV: ${{ github.event_name == 'push' && 'production' || format('pr-{0}', github.event.number) }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - NEON_API_KEY: ${{ secrets.NEON_API_KEY }} - NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - ELECTRIC_API: ${{ secrets.ELECTRIC_API }} - ELECTRIC_ADMIN_API: ${{ secrets.ELECTRIC_ADMIN_API }} - # HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO + DEPLOY_ENV: ${{ github.event_name == 'push' && 'production' || format('pr-{0}', github.event.number) }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + NEON_API_KEY: ${{ secrets.NEON_API_KEY }} + NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + ELECTRIC_API: ${{ secrets.ELECTRIC_API }} + ELECTRIC_ADMIN_API: ${{ secrets.ELECTRIC_ADMIN_API }} + # HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/teardown_examples_pr_stack.yml b/.github/workflows/teardown_examples_pr_stack.yml new file mode 100644 index 0000000000..3f7f3bcff8 --- /dev/null +++ b/.github/workflows/teardown_examples_pr_stack.yml @@ -0,0 +1,62 @@ +name: Teardown Examples PR stack + +on: + pull_request: + paths: ['examples/*/**'] + types: [closed] + +concurrency: + group: examples-pr-${{ github.event.number }} + +jobs: + teardown-pr-stack: + name: Teardown Examples PR stack + environment: Pull request + runs-on: ubuntu-latest + + env: + DEPLOY_ENV: ${{ github.event_name == 'push' && 'production' || format('pr-{0}', github.event.number) }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + NEON_API_KEY: ${{ secrets.NEON_API_KEY }} + NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + ELECTRIC_API: ${{ secrets.ELECTRIC_API }} + ELECTRIC_ADMIN_API: ${{ secrets.ELECTRIC_ADMIN_API }} + # HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO + + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Cache SST state + uses: actions/cache@v4 + with: + path: .sst + key: sst-cache-${{ github.event.number }}-${{ runner.os }} + restore-keys: | + sst-cache-${{ runner.os }} + + - name: Remove Linearlite + working-directory: examples/linearlite + run: | + export PR_NUMBER=${{ github.event.number }} + echo "Removing stage pr-$PR_NUMBER" + pnpm sst remove --stage "pr-$PR_NUMBER" + + - name: Remove NextJs example + working-directory: examples/nextjs-example + run: | + export PR_NUMBER=${{ github.event.number }} + echo "Removing stage pr-$PR_NUMBER" + pnpm sst remove --stage "pr-$PR_NUMBER" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75ad3bf0ff..20179f0f3d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8311,7 +8311,7 @@ snapshots: '@babel/traverse': 7.25.9 '@babel/types': 7.26.0 convert-source-map: 2.0.0 - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.7 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -8491,7 +8491,7 @@ snapshots: '@babel/parser': 7.26.2 '@babel/template': 7.25.9 '@babel/types': 7.26.0 - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.7 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -9150,7 +9150,7 @@ snapshots: '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.7 espree: 9.6.1 globals: 13.24.0 ignore: 5.3.2 @@ -9204,7 +9204,7 @@ snapshots: '@humanwhocodes/config-array@0.13.0': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.7 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -11920,6 +11920,10 @@ snapshots: dependencies: ms: 2.0.0 + debug@4.3.7: + dependencies: + ms: 2.1.3 + debug@4.3.7(supports-color@5.5.0): dependencies: ms: 2.1.3 @@ -12493,7 +12497,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.7 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2