chore: Configure Renovate #1522
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: | |
hasDocsEnv: ${{ steps.list-environments.outputs.hasDocsEnv }} | |
hasStorybookEnv: ${{ steps.list-environments.outputs.hasStorybookEnv }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: List repo environments | |
id: list-environments | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
github-token: ${{ secrets.CHANGESETS_TOKEN }} | |
script: | | |
const pull_number = context.issue.number; | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
// List environments | |
const environments = await github.rest.repos.getAllEnvironments({ | |
owner: owner, | |
repo: repo, | |
per_page: 100, | |
}); | |
const envList = environments.data.environments.map(env => env.name); | |
// Check for existence of specific environments | |
const hasDocsEnv = envList.includes(`pie-docs-pr-${pull_number}`); | |
const hasStorybookEnv = envList.includes(`pie-storybook-pr-${pull_number}`); | |
core.setOutput('hasDocsEnv', hasDocsEnv); | |
core.setOutput('hasStorybookEnv', hasStorybookEnv); | |
- name: Delete associated docs environments | |
if: steps.list-environments.outputs.hasDocsEnv == 'true' | |
uses: ./.github/actions/amplify-teardown | |
with: | |
gh-app-id: ${{ secrets.GH_APP_ID }} | |
gh-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
amplify-app-id: dvskdcoepjoyf | |
aws-region: 'eu-west-1' | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
environment-name: pie-docs-pr-${{ github.event.number }} | |
branch-name: 'pr${{ github.event.number }}' | |
- name: Delete associated storybook environment | |
if: steps.list-environments.outputs.hasStorybookEnv == 'true' | |
uses: ./.github/actions/amplify-teardown | |
with: | |
gh-app-id: ${{ secrets.GH_APP_ID }} | |
gh-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
amplify-app-id: d17ja0ul7nrdy0 | |
aws-region: 'eu-west-1' | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
environment-name: pie-storybook-pr-${{ github.event.number }} | |
branch-name: 'pr${{ github.event.number }}' |