Remove stale staging resources #28586
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 stale staging resources | |
# **What it does**: | |
# This cleans up any rogue staging applications and environments that outlasted | |
# the closure of their corresponding pull requests. | |
# **Why we have it**: | |
# Staging applications and environments should be destroyed after their | |
# corresponding pull request is closed or merged, especially to save money spent | |
# on Heroku App staging deployments for closed PRs. | |
# **Who does it impact**: | |
# Anyone with a closed, spammy, or deleted pull request in docs or docs-internal. | |
on: | |
schedule: | |
- cron: '15,45 * * * *' # every thirty minutes at :15 and :45 | |
permissions: | |
actions: read | |
contents: read | |
deployments: write | |
pull-requests: write | |
jobs: | |
remove_stale_staging_apps: | |
name: Remove stale staging apps | |
if: ${{ github.repository == 'github/docs-internal' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo's default branch | |
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
- name: Setup Node | |
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 | |
with: | |
node-version: 16.13.x | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Run script | |
run: script/remove-stale-staging-apps.js | |
env: | |
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
remove_stale_staging_envs: | |
name: Remove stale staging environments | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo's default branch | |
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
- name: Setup Node | |
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 | |
with: | |
node-version: 16.13.x | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Run script | |
run: script/remove-stale-staging-envs.js | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ELEVATED_TOKEN: ${{ secrets.DOCS_BOT_FR }} | |
REPO: ${{ github.repository }} | |
RUN_ID: ${{ github.run_id }} |