-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (33 loc) · 1.13 KB
/
enforce-flow.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
# This GitHub action enforces that only merges from previous env will be accepted to next env
# for example: only merges from stage will be accepted into main (prod)
name: Enforce Flow
on:
push:
branches:
- main
- stage
pull_request:
branches:
- main
- stage
jobs:
enforce_flow:
name: Enforce Flow
runs-on: ubuntu-latest
steps:
# This is where we would add a check for merging into stage if we add an environment before stage
- name: No need to check if merging into stage
if: github.base_ref == 'stage'
run: exit 0
# If merging into main, ensure it is from stage
- name: Fail if PR is not from stage
if: github.base_ref == 'main' && github.head_ref != 'stage'
run: |
echo "Error: Pull request to main must come from the stage branch."
echo "This pull request is from ${{ github.head_ref }}"
exit 1
- name: Verify if tests passed on stage branch
run: |
echo "Checking if Tests passed on stage..."
if: ${{ github.event.pull_request.head.ref == 'stage' }}
continue-on-error: false