Skip to content

[Workflow] - Student provider (consumer-driven) #8

[Workflow] - Student provider (consumer-driven)

[Workflow] - Student provider (consumer-driven) #8

name: '[Workflow] - Student provider (consumer-driven)'
on:
workflow_dispatch:
inputs:
environment:
description: "Environment to deploy to. Select 'none' for build only."
required: true
type: choice
default: 'none'
options: [ none, test, production ]
env:
MAVEN_CLI_OPTS: >
--batch-mode --errors --fail-at-end --show-version
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
jobs:
build_and_verify:
name: Build & Verify Pacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { distribution: 'temurin', java-version: '21', cache: 'maven' }
- name: Build and Verify with Maven
env:
PACT_BROKER_BASE_URL: ${{ vars.PACT_BROKER_BASE_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
run: >
mvn -f student-provider/pom.xml $MAVEN_CLI_OPTS clean install
-Dpact.verifier.publishResults=true
-Dpact.provider.version=${{ github.sha }}
-Dpact.provider.branch=${{ github.ref_name }}
-Dpactbroker.consumerversionselectors.rawjson='[{"deployed":true}, {"latest":true}]'
deploy_sequence:
name: Deploy
needs: build_and_verify
if: github.event.inputs.environment != 'none'
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v4
- name: Setup Pact CLI
uses: ./.github/actions/pact-cli-setup
- name: Can I Deploy?
uses: ./.github/actions/can-i-deploy
with:
pact_broker_base_url: ${{ vars.PACT_BROKER_BASE_URL }}
pacticipant: 'student-provider'
version: ${{ github.sha }}
environment: ${{ github.event.inputs.environment }}
pact_broker_token: ${{ secrets.PACTFLOW_TOKEN }}
- name: Deploy
uses: ./.github/actions/deploy
with:
pacticipant: 'student-provider'
version: ${{ github.sha }}
environment: ${{ github.event.inputs.environment }}
- name: Tag Deployment
uses: ./.github/actions/tagging
with:
pact_broker_base_url: ${{ vars.PACT_BROKER_BASE_URL }}
pacticipant: 'student-provider'
version: ${{ github.sha }}
environment: ${{ github.event.inputs.environment }}
pact_broker_token: ${{ secrets.PACTFLOW_TOKEN }}