Skip to content

Commit

Permalink
Merge pull request #1 from miriamgoldman/multidev-deletion
Browse files Browse the repository at this point in the history
introduce closed PR workflow
  • Loading branch information
miriamgoldman authored Jul 30, 2024
2 parents d9f64c5 + bc324b9 commit 99014f8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/multidev-removal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Delete closed PR multidevs
on:
pull_request:
types: [closed]

jobs:
configure_env:
name: Configure environment and Terminus
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

identify_sites:
runs-on: ubuntu-latest
needs: configure_env
steps:
- name: Install Terminus
uses: pantheon-systems/terminus-github-actions@main
with:
pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }}


remove_pr_env:
runs-on: ubuntu-latest
needs: [ identify_sites, configure_env ]
if: github.event_name = 'pull_request'
steps:
- name: Install Terminus
uses: pantheon-systems/terminus-github-actions@v1
with:
pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }}

- name: Determine target environment and maybe delete it
run: |
# Use the PR number as the environment name
env=$(echo ${{ github.ref_name }} | sed 's|^\([0-9]*\)/.*|pr-\1|')
# Ensure environment name is 11 characters or less and has no special characters
env="${env:0:11}"
env=$(echo "$env" | sed 's/[^a-zA-Z0-9]/-/g')
terminus env:delete ${{ vars.SITE_NAME }}.$env --delete-branch --yes
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Intermediate GitHub Actions Workflow

- contains automatic multidev deletion (separate job)
- includes basic BackstopJS VRT (separate job)
- includes basic BackstopJS VRT (separate job)

## Multi-Dev Deletion

A workflow is in place that checks for multi-devs associated to an open PR. If it detects a multi-dev, but there is no associated PR, said environment is removed.

0 comments on commit 99014f8

Please sign in to comment.