Skip to content

Commit

Permalink
update: update github actions to run test case when PR is raised
Browse files Browse the repository at this point in the history
Signed-off-by: SurabhiAngadi <surabhia@sanketika.in>
  • Loading branch information
SurabhiAngadi committed Jan 22, 2024
1 parent 89db459 commit 9847876
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
name: Obsrv api service build and deploy workflow
name: Obsrv API Service Build and Deploy workflow
run-name: Workflow run for ${{ github.ref }}
on:
push:
tags:
- '*'

- "*"
workflow_dispatch:
inputs:
aws-deploy:
type: boolean
required: true
default: false
pull_request:
types:
- opened
- synchronize
jobs:
check-tag:
runs-on: ubuntu-latest
Expand All @@ -15,9 +24,29 @@ jobs:
id: tag-checker
run: |
(echo -n TRIGGER_ALLOWED= && echo 'print("${{ github.ref_name }}".split("_")[0] not in "${{ vars.CURRENT_RELEASE }}")' | python3) >> "$GITHUB_OUTPUT"
run-test-cases:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.10

- name: Checkout code
uses: actions/checkout@v2

- name: Run test cases
run: |
cd api-service/src/test
npm install
npm run test
docker-build-api-service:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Login to docker hub
Expand All @@ -35,7 +64,7 @@ jobs:

docker-build-command-service:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Login to docker hub
Expand All @@ -52,7 +81,7 @@ jobs:

aws-deploy:
needs: [check-tag, docker-build-api-service, docker-build-command-service]
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && github.event.inputs.aws-deploy == 'true'
runs-on: ubuntu-latest
environment: aws-dev
steps:
Expand Down

0 comments on commit 9847876

Please sign in to comment.