Skip to content

ConsumerCI

ConsumerCI #99

Workflow file for this run

name: ConsumerCI
on:
workflow_dispatch:
inputs:
application_name:
description: name of consumer
required: true
default: 'SmartBearCoin-Payments-UI'
provider_name:
description: name of provider
required: true
default: 'SmartBearCoin-Payee-Provider'
demo_deploy:
description: skip deployment steps for demo
required: true
default: 'false'
push:
paths:
- 'smartbearcoin-payments-ui/**'
- '.github/workflows/ConsumerCI.yml'
- 'oas/**'
pull_request:
branches: ['main', 'mar2024-webinar-prep']
paths:
- 'smartbearcoin-payments-ui/**'
- '.github/workflows/ConsumerCI.yml'
- 'oas/**'
env:
version: ${{ github.sha }}
PACT_BROKER_BASE_URL: https://smartbear.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
application_folder: smartbearcoin-payments-ui
application_name: ${{ github.event.inputs.application_name }}
application_name_default: SmartBearCoin-Payments-UI
provider_name: ${{ github.event.inputs.provider_name }}
provider_name_default: SmartBearCoin-Payee-Provider
jobs:
setup:
name: 🏗️ setup
runs-on: ubuntu-latest
steps:
- run: echo "application_name=${application_name:-${application_name_default}}" >> $GITHUB_ENV
- run: echo "provider_name=${provider_name:-${provider_name_default}}" >> $GITHUB_ENV
outputs:
PACT_CONSUMER: ${{ env.application_name }}
PACT_PROVIDER: ${{ env.provider_name }}
test:
needs: setup
runs-on: ubuntu-latest
env:
PACT_CONSUMER: ${{ needs.setup.outputs.PACT_CONSUMER }}
PACT_PROVIDER: ${{ needs.setup.outputs.PACT_PROVIDER }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: cd ${{ env.application_folder }} && npm ci
- run: cd ${{ env.application_folder }} && npm test
- uses: pactflow/actions/[email protected]
env:
pactfiles: ${{ env.application_folder }}/pacts
can-i-deploy-to-acc:
needs: [setup, test]
runs-on: ubuntu-latest
env:
deploy_target: acceptance
steps:
- name: can-i-deploy ${{ env.application_name }} to ${{ env.deploy_target }}
uses: pactflow/actions/[email protected]
env:
to_environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
can-i-deploy-to-production:
needs: [setup, test]
runs-on: ubuntu-latest
env:
deploy_target: production
steps:
- name: can-i-deploy ${{ env.application_name }} to ${{ env.deploy_target }}
uses: pactflow/actions/[email protected]
env:
to_environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
deploy-to-acc:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/mar2024-webinar-prep'
needs: [setup, can-i-deploy-to-acc]
runs-on: ubuntu-latest
env:
deploy_target: acceptance
REACT_APP_API_BASE_URL: https://sbdevrel-fua-smartbearcoin-acc1.azurewebsites.net/api
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Build site
run: |
cd ${{ env.application_folder }}
npm ci
npm run build
- name: Deploy website to ${{ env.deploy_target }} environment
uses: nwtgck/[email protected]
with:
publish-dir: './${{ env.application_folder }}/build'
alias: ${{ env.deploy_target }}
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: record-deployment ${{ env.application_name }} to ${{ env.deploy_target }}
uses: pactflow/actions/[email protected]
env:
environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
deploy-to-production:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/mar2024-webinar-prep'
needs: [setup, can-i-deploy-to-production, deploy-to-acc]
runs-on: ubuntu-latest
env:
deploy_target: production
REACT_APP_API_BASE_URL: https://sbdevrel-fua-smartbearcoin-prd1.azurewebsites.net/api
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Build site
run: |
cd ${{ env.application_folder }}
npm ci
npm run build
- name: Deploy website to ${{ env.deploy_target }} environment
uses: nwtgck/[email protected]
with:
publish-dir: './${{ env.application_folder }}/build'
production-branch: main
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: record-deployment ${{ env.application_name }} to ${{ env.deploy_target }}
uses: pactflow/actions/[email protected]
env:
environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}