Skip to content

Commit

Permalink
Refactor github action (#13)
Browse files Browse the repository at this point in the history
When workflow_run is used the workflow will checkout the default branch which
will not work with our workflow.  We want the workflow to checkout the branch
that trigger the event.  The suggestion is to change workflow_run to workflow_call[1]

[1] https://github.com/orgs/community/discussions/72097#discussioncomment-7376117
  • Loading branch information
zaro0508 authored Jan 15, 2025
1 parent beb0826 commit 959cc9b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: deploy-dev

on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- dev
push:
branches: ['dev']

jobs:
test:
uses: ./.github/workflows/test.yaml
with:
environment: dev
aws-deploy:
uses: "./.github/workflows/aws-deploy.yaml"
with:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: deploy-prod

on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- prod
push:
branches: ['prod']

jobs:
test:
uses: ./.github/workflows/test.yaml
with:
environment: prod
aws-deploy:
uses: "./.github/workflows/aws-deploy.yaml"
with:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/deploy-stage.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: deploy-stage

on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- stage
push:
branches: ['stage']

jobs:
test:
uses: ./.github/workflows/test.yaml
with:
environment: stage
aws-deploy:
uses: "./.github/workflows/aws-deploy.yaml"
with:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pr-check

on:
pull_request:
branches: ['*']

jobs:
test:
uses: ./.github/workflows/test.yaml
with:
environment: dev
14 changes: 7 additions & 7 deletions .github/workflows/check.yml → .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: check
name: test

on:
pull_request:
branches: ['*']
push:
branches: ['*']

workflow_call:
inputs:
environment:
required: true
type: string
jobs:
unit-tests:
runs-on: ubuntu-latest
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Generate cloudformation
uses: youyo/aws-cdk-github-actions@v2
env:
ENV: dev
ENV: ${{ inputs.environment }}
with:
cdk_subcommand: 'synth'
actions_comment: false
Expand Down

0 comments on commit 959cc9b

Please sign in to comment.