-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (35 loc) · 1.28 KB
/
multidev-removal.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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"
- 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: [ 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|')
echo "Source is ${{ github.head_ref }} | 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