Only allow staging to run off of the master branch

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-02-07 05:58:19 +00:00 committed by Pedro Algarvio
parent 5dfc22c28b
commit 7b395348b3
2 changed files with 33 additions and 7 deletions

View file

@ -26,8 +26,8 @@ concurrency:
jobs:
check-permissions:
name: Check Permissions
check-requirements:
name: Check Requirements
runs-on: ubuntu-latest
steps:
- name: Check For Admin Permission
@ -36,11 +36,21 @@ jobs:
require: admin
username: ${{ github.triggering_actor }}
- name: Check Branch
run: |
echo "Trying to run the staging workflow from branch ${{ github.ref_name }}"
if [ "${{ github.ref_name }}" != "master" ]; then
echo "Running the staging workflow from the ${{ github.ref_name }} branch is not allowed"
exit 1
else
echo "Allowed"
fi
prepare-workflow:
name: Prepare Workflow Run
runs-on: ubuntu-latest
needs:
- check-permissions
- check-requirements
outputs:
jobs: ${{ steps.define-jobs.outputs.jobs }}
runners: ${{ steps.runner-types.outputs.runners }}
@ -873,7 +883,7 @@ jobs:
if: always()
runs-on: ubuntu-latest
needs:
- check-permissions
- check-requirements
- prepare-workflow
- pre-commit
- lint

View file

@ -26,10 +26,11 @@ concurrency:
<%- block pre_jobs %>
<%- do prepare_workflow_needs.append('check-permissions') %>
<%- set job_name = "check-requirements" %>
check-permissions:
name: Check Permissions
<{ job_name }>:
<%- do prepare_workflow_needs.append(job_name) %>
name: Check Requirements
runs-on: ubuntu-latest
steps:
- name: Check For Admin Permission
@ -37,6 +38,21 @@ concurrency:
with:
require: admin
username: ${{ github.triggering_actor }}
- name: Check Branch
run: |
{#-
Should we allow other branches?
#}
echo "Trying to run the staging workflow from branch ${{ github.ref_name }}"
if [ "${{ github.ref_name }}" != "master" ]; then
echo "Running the staging workflow from the ${{ github.ref_name }} branch is not allowed"
exit 1
else
echo "Allowed"
fi
<%- endblock pre_jobs %>