Skip to content

Commit

Permalink
Fix chained Workflows not running on correct branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinou01 committed Aug 16, 2023
1 parent eb9a651 commit 91d31e6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: "Build Docker Images"

on:
workflow_run:
workflows: ["Run Tests"]
types:
- completed
workflow_call

jobs:
build:
Expand Down Expand Up @@ -38,3 +35,4 @@ jobs:

- name: "Build Load"
run: gcloud builds submit --config=dockerfiles/cloudbuild.yml --substitutions=_IMAGE_NAME="load" .

14 changes: 14 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

name: "On Pull Request"

on:
pull_request:
branches: [ "prod", "dev" ]

jobs:
on-push:
runs-on: ubuntu-latest

steps:
- name: "Run Tests"
uses: ./.github/workflows/test.yml@${GITHUB_REF##*/}
18 changes: 18 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

name: "On Push"

on:
push:
branches: [ "prod", "dev" ]

jobs:
on-push:
runs-on: ubuntu-latest

steps:
- name: "Run Tests"
uses: ./.github/workflows/test.yml@${GITHUB_REF##*/}
- name: "Build Images"
uses: ./.github/workflows/build_images.yml@${GITHUB_REF##*/}
- name: "Terraform Apply"
uses: ./.github/workflows/terraform.yml@${GITHUB_REF##*/}
5 changes: 1 addition & 4 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: 'Terraform Apply'

on:
workflow_run:
workflows: ["Build Docker Images"]
types:
- completed
workflow_call

jobs:
terraform:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
name: 'Run Tests'

on:
push:
branches: [ "prod", "dev" ]
pull_request:
branches: [ "prod", "dev" ]
workflow_call

permissions:
contents: read
Expand Down

0 comments on commit 91d31e6

Please sign in to comment.