|
| 1 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json |
| 2 | +--- |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | +permissions: |
| 8 | + id-token: write |
| 9 | + contents: read |
| 10 | + pull-requests: write |
| 11 | + deployments: write |
| 12 | + repository-projects: write |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | +env: |
| 17 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 18 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 19 | +jobs: |
| 20 | + deploy: |
| 21 | + name: Destroy staging |
| 22 | + runs-on: "ubuntu-latest" |
| 23 | + environment: |
| 24 | + name: Staging \#${{ github.event.pull_request.number }} |
| 25 | + url: https://docs-staging-${{ github.event.pull_request.number }}.icssc.club |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: lts/hydrogen |
| 35 | + - name: Install pnpm |
| 36 | + uses: pnpm/action-setup@v2 |
| 37 | + with: |
| 38 | + version: 8 |
| 39 | + run_install: false |
| 40 | + - name: Get pnpm store directory |
| 41 | + id: pnpm-cache |
| 42 | + shell: bash |
| 43 | + run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 44 | + - name: Setup pnpm cache |
| 45 | + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 |
| 46 | + with: |
| 47 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 48 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 49 | + restore-keys: ${{ runner.os }}-pnpm-store- |
| 50 | + - name: Install dependencies |
| 51 | + run: pnpm install --frozen-lockfile |
| 52 | + - name: Destroy app |
| 53 | + run: pnpm sst remove --stage staging-${{ github.event.pull_request.number }} |
| 54 | + - name: Set API staging environment to inactive |
| 55 | + uses: strumwolf/delete-deployment-environment@195215d2c5602aee6fb4b9cf0853970decca9e7a # v2.3.0 |
| 56 | + with: |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + environment: Staging \#${{ github.event.pull_request.number }} |
| 59 | + onlyDeactivateDeployments: true |
0 commit comments