From 9422fdead742798d70d56345c15ac49c50f3ccc7 Mon Sep 17 00:00:00 2001 From: Miriam Goldman Date: Mon, 29 Jul 2024 15:30:45 -0400 Subject: [PATCH] tweak --- .github/workflows/standard-workflow.yml | 28 ++++++++++--------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/standard-workflow.yml b/.github/workflows/standard-workflow.yml index 545c0da78..6043fe9fe 100644 --- a/.github/workflows/standard-workflow.yml +++ b/.github/workflows/standard-workflow.yml @@ -2,10 +2,10 @@ name: Deploy to Pantheon on: push: branches: - - master + - main pull_request: branches: - - master + - main jobs: configure_env: name: Configure environment and Terminus @@ -59,22 +59,10 @@ jobs: with: pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} - # - name: Find canary sites - # id: findSites - # run: | - # # Get list of sites with the canary tag using the upstream in our organization - # SITES=$(terminus org:site:list --upstream="${{ vars.UPSTREAM_GUID }}" --tag="${{ vars.CANARY_TAG_NAME }}" --field="name" ${{ vars.ORG_GUID }}) - # SITE_JSON=$(echo $SITES | jq -R -s -c 'split("\n") | map(select(length > 0))') - # # Export the list of sites for the matrix - # echo "sites=$SITE_JSON" >> $GITHUB_OUTPUT - deploy_to_pantheon: runs-on: ubuntu-latest needs: [ identify_sites, configure_env ] - # strategy: - # matrix: - # site: ${{ fromJSON(needs.identify_sites.outputs.sites) }} steps: - name: Checkout uses: actions/checkout@v4 @@ -96,8 +84,14 @@ jobs: - name: Determine target environment for deploy run: | # Identify environment based on branch name - env=${{ github.ref_name }} - if [ "$env" == "master" ]; then + if [ "${{ github.event_name }}" = "pull_request" ]; then + # Use the PR number as the environment name + env=$(echo ${{ github.ref_name }} | sed 's|^\([0-9]*\)/.*|pr-\1|') + else + # Use the branch name as the environment name + env=${{ github.ref_name }} + fi + if [ "$env" == "main" ]; then env="dev" fi @@ -131,7 +125,7 @@ jobs: git push pantheon ${{ github.ref_name }}:$branch --force spin_down: - name: Spin down environment + name: Spin down needs: deploy_to_pantheon if: always() runs-on: ubuntu-latest