Skip to content

Commit

Permalink
Remove github.event.pull_request.head.ref
Browse files Browse the repository at this point in the history
  • Loading branch information
nickschuch committed Oct 31, 2023
1 parent 97def9c commit ff39448
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/preview-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: Create Preview Environment
on:
workflow_call:
inputs:
ref:
type: string
description: The fully-formed ref of the branch or tag that triggered the workflow run.
image:
type: string
default: skpr/preview:2.x
description: Region which this preview infrastructure resides.
description: Image to use for this workflow.
region:
type: string
default: ap-southeast-2
Expand All @@ -33,10 +36,10 @@ on:
outputs:
version:
description: The preview environment name
value: ${{ jobs.info.outputs.preview_name }}
value: ${{ jobs.create.outputs.preview-name }}
url:
description: The URL of the preview environment
value: ${{ jobs.info.outputs.preview_domain }}
value: ${{ jobs.create.outputs.preview-domain }}

env:
AWS_REGION: ${{ inputs.region }}
Expand All @@ -49,8 +52,8 @@ env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.SKPR_PREVIEW_PASSWORD }}

jobs:
create-preview-environment:
name: Delete Preview Environment
create:
name: Create Preview Environment
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
container:
Expand All @@ -64,7 +67,7 @@ jobs:
- name: ℹ️ Get Preview Environment Information
id: info
run: |
PREVIEW_NAME=${{ github.event.pull_request.head.ref }}
PREVIEW_NAME=${{ inputs.ref }}
PREVIEW_NAME=$(echo $PREVIEW_NAME | sed -r 's/[^a-zA-Z0-9-]//g' | tr '[:upper:]' '[:lower:]')
PREVIEW_DOMAIN=${PREVIEW_NAME}.${{ inputs.domain }}
echo "preview_name=$PREVIEW_NAME" >> $GITHUB_OUTPUT
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/preview-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: Delete Preview Environment
on:
workflow_call:
inputs:
ref:
type: string
description: The fully-formed ref of the branch or tag that triggered the workflow run.
image:
type: string
default: skpr/preview:2.x
description: Region which this preview infrastructure resides.
description: Image to use for this workflow.
region:
type: string
default: ap-southeast-2
Expand All @@ -22,6 +25,10 @@ on:
required: true
skpr_preview_password:
required: true
outputs:
version:
description: The preview environment name
value: ${{ jobs.delete.outputs.preview-name }}

env:
AWS_REGION: ${{ inputs.region }}
Expand All @@ -31,21 +38,20 @@ env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.SKPR_PREVIEW_PASSWORD }}

jobs:
create-preview:
name: Create Preview Environment
delete:
name: Delete Preview Environment
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
outputs:
preview-name: ${{ steps.info.outputs.preview_name }}
preview-domain: ${{ steps.info.outputs.preview_domain }}
steps:
- name: ⬇️ Checkout Code
uses: actions/checkout@v3
- name: ℹ️ Get Preview Environment Information
id: info
run: |
PREVIEW_NAME=${{ github.event.pull_request.head.ref }}
PREVIEW_NAME=${{ inputs.ref }}
PREVIEW_NAME=$(echo $PREVIEW_NAME | sed -r 's/[^a-zA-Z0-9-]//g' | tr '[:upper:]' '[:lower:]')
echo "preview_name=$PREVIEW_NAME" >> $GITHUB_OUTPUT
- name: 🧹 Delete Preview Environment
Expand Down

0 comments on commit ff39448

Please sign in to comment.