Skip to content

Commit

Permalink
Add a separate workflow for provider
Browse files Browse the repository at this point in the history
  • Loading branch information
prbhlnkr123 committed May 17, 2024
1 parent f118bfa commit bee7b77
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
name: Build

on:
push:
workflow_dispatch:
name: Pact-Consumer

env:
PACT_FLOW_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
Expand All @@ -11,7 +7,6 @@ env:
GIT_REF: ${{ github.ref }}
GIT_BRANCH: ${{ github.ref_name }}
CONSUMER: "bookClient"
PROVIDER: "bookProvider"

jobs:
run_contract_tests:
Expand Down Expand Up @@ -63,6 +58,3 @@ jobs:
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
pactfoundation/pact-cli:latest \
pact-broker record-deployment --broker-base-url=$PACT_FLOW_BASE_URL --broker-token=$PACT_FLOW_TOKEN --pacticipant $CONSUMER --version $GIT_COMMIT --environment 'test'
- name: Run provider test
run: ./gradlew runProviderTest
44 changes: 44 additions & 0 deletions .github/workflows/pact-provider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Pact-Provider

env:
PACT_FLOW_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
PACT_FLOW_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
GIT_COMMIT: ${{ github.sha }}
GIT_REF: ${{ github.ref }}
GIT_BRANCH: ${{ github.ref_name }}
PROVIDER: "bookProvider"

jobs:
run_contract_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Run provider test
run: ./gradlew runProviderTest

- name: can-I-deploy
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_FLOW_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
pactfoundation/pact-cli:latest \
pact-broker can-i-deploy --pacticipant $CONSUMER --latest
- name: Deploy to Test
run: echo "Deploy to TEST Environment"

- name: Record Deployment for TEST
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_FLOW_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
pactfoundation/pact-cli:latest \
pact-broker record-deployment --broker-base-url=$PACT_FLOW_BASE_URL --broker-token=$PACT_FLOW_TOKEN --pacticipant $CONSUMER --version $GIT_COMMIT --environment 'test'

0 comments on commit bee7b77

Please sign in to comment.