Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/check-pr-enforcer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Pull request check enforcer'
name: "Pull request check enforcer"

on:
pull_request:
Expand All @@ -9,15 +9,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check source branch
if: github.base_ref == 'main' && github.head_ref != 'release/**'
- name: PR summary
run: |
echo "ERROR: You can only merge to main from a release/** branch."
exit 1
echo "PR number: #${{ github.event.number }}"
echo "Source branch: '${{ github.head_ref }}'"
echo "Destination branch: '${{ github.base_ref }}'"

- name: Check destination branch
if: github.head_ref == 'release/**' && github.base_ref != 'main'
- name: PR rules
run: |
echo "ERROR: You can only merge a release/** branch into main."
exit 1

if [[ "${{ github.base_ref }}" == 'main' ]]; then
if [[ "${{ github.head_ref }}" =~ ^release/ ]]; then
echo "Merge from 'release/**' to 'main' branch is allowed."
exit 0
else
echo "ERROR: You can only merge to 'main' from a 'release/**' branch."
exit 1
fi
else
echo "Destination branch is not 'main', merge is allowed."
fi
50 changes: 12 additions & 38 deletions .github/workflows/wf-tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,18 @@ run-name: Workflow Tester

on:
workflow_dispatch:
inputs:
tfAction:
description: "Terraform action to run"
type: choice
options:
- plan
- apply
- destroy
default: plan
push:
branches:
- disabled-samples/*

env:
TFPLAN_FILE_NAME: "tfplan"

jobs:
terraform-plan:
name: Terraform Plan
uses: ./.github/workflows/wf-tf-plan.yaml
if: ( github.event_name == 'push' || github.event.inputs.tfAction == 'plan' )
permissions:
id-token: write
secrets: inherit

terraform-apply:
name: Terraform Apply
uses: ./.github/workflows/wf-tf-apply.yaml
needs: terraform-plan
if: ( github.event_name == 'push' || github.event.inputs.tfAction == 'apply') && needs.terraform-plan.outputs.tfplanExitCode == 2
permissions:
id-token: write
secrets: inherit
check_branch:
name: Check branches
runs-on: ubuntu-latest

terraform-destroy:
name: Terraform Destroy
uses: ./.github/workflows/wf-tf-destroy.yaml
if: ( github.event_name == 'workflow_dispatch' && github.event.inputs.tfAction == 'destroy' )
permissions:
id-token: write
secrets: inherit
steps:
- name: Evaluate ref values
run: |
echo "Base ref: ${{ github.base_ref }}"
echo "Head ref: ${{ github.head_ref }}"
echo "Ref: ${{ github.ref }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name glob: ${{ github.ref_name == 'feature/**' }}"