WCP-2562: bump cookie banner to 1.x #128
Workflow file for this run
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
name: Remove PR Previews | |
on: | |
pull_request: | |
types: [closed] | |
concurrency: preview-teardown-${{ github.ref }} | |
jobs: | |
list-environments: | |
runs-on: ubuntu-latest | |
outputs: | |
hasNextJs14Env: ${{ steps.list-environments.outputs.hasNextJs14Env }} | |
hasNuxtEnv: ${{ steps.list-environments.outputs.hasNuxtEnv }} | |
hasVanillaJsEnv: ${{ steps.list-environments.outputs.hasVanillaJsEnv }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: List repo environments | |
id: list-environments | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.PIE_BOT_TOKEN }} | |
script: | | |
const pullRequestNumber = context.payload.pull_request.number; | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
console.log(`Pull Request Number: ${pullRequestNumber}`); | |
// List environments | |
const { data: { environments } } = await github.rest.repos.getAllEnvironments({ | |
owner: owner, | |
repo: repo, | |
per_page: 100, | |
}); | |
const envList = environments.map(env => env.name); | |
console.log('Environment List:', envList); | |
// Check for existence of specific environments | |
const hasNextJs14Env = envList.includes(`nextjs-app-v14-pr-${pullRequestNumber}`); | |
const hasNuxtEnv = envList.includes(`nuxt-app-pr-${pullRequestNumber}`); | |
const hasVanillaJsEnv = envList.includes(`vanilla-app-pr-${pullRequestNumber}`); | |
console.log('Has NextJS 14 Env:', hasNextJs14Env); | |
console.log('Has Nuxt Env:', hasNuxtEnv); | |
console.log('Has VanillaJS Env:', hasVanillaJsEnv); | |
core.setOutput('hasNextJs14Env', hasNextJs14Env ? 'true' : 'false'); | |
core.setOutput('hasNuxtEnv', hasNuxtEnv ? 'true' : 'false'); | |
core.setOutput('hasVanillaJsEnv', hasVanillaJsEnv ? 'true' : 'false'); | |
- name: Delete associated NextJS 14 app environment | |
if: ${{ steps.list-environments.outputs.hasNextJs14Env == 'true' }} | |
uses: ./.github/actions/amplify-teardown | |
with: | |
github-token: ${{ secrets.PIE_BOT_TOKEN }} | |
amplify-app-id: d1xxjuy6vbm7pk | |
aws-region: 'eu-west-1' | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
environment-name: nextjs-app-v14-pr-${{ github.event.pull_request.number }} | |
branch-name: 'pr${{ github.event.pull_request.number }}' | |
- name: Delete associated Nuxt app environment | |
if: ${{ steps.list-environments.outputs.hasNuxtEnv == 'true' }} | |
uses: ./.github/actions/amplify-teardown | |
with: | |
github-token: ${{ secrets.PIE_BOT_TOKEN }} | |
amplify-app-id: d36dan3bxjue8c | |
aws-region: 'eu-west-1' | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
environment-name: nuxt-app-pr-${{ github.event.pull_request.number }} | |
branch-name: 'pr${{ github.event.pull_request.number }}' | |
- name: Delete associated Vanilla app environment | |
if: ${{ steps.list-environments.outputs.hasVanillaJsEnv == 'true' }} | |
uses: ./.github/actions/amplify-teardown | |
with: | |
github-token: ${{ secrets.PIE_BOT_TOKEN }} | |
amplify-app-id: d2vb6sjgivffb3 | |
aws-region: 'eu-west-1' | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
environment-name: vanilla-app-pr-${{ github.event.pull_request.number }} | |
branch-name: 'pr${{ github.event.pull_request.number }}' |