sbt-openapi-generator icon indicating copy to clipboard operation
sbt-openapi-generator copied to clipboard

Create triggered workflow from openapi-generator releases

Open jimschubert opened this issue 4 years ago • 1 comments

Tracking item to update/build/test on openapi-generator releases. If successful, we can commit the new version and trigger a release.

jimschubert avatar Mar 01 '20 18:03 jimschubert

I looked into this and it doesn't seem too bad. In openapi-generator, we can add a triggered build on release similar to this:

name: Trigger

on:
  push:
    branches: [ master ]
  release:
    types: [ published ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2
    - name: Set env
      run:  echo ::set-env name=CONTENT::$(cat ${GITHUB_WORKSPACE}/value.txt)
    - name: Repository Dispatch
      uses: peter-evans/[email protected]
      with:
        token: ${{ secrets.REPO_TOKEN }}
        repository: jimschubert/poc-triggered-workflow-orchestrator
        event-type: triggered-event
        client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "content": "${{env.CONTENT}}"}'

And respond to the event in this repo (or some orchestrating repo) like this:

# Example via https://github.com/marketplace/actions/repository-dispatch
name: Repository Dispatch
on:
  repository_dispatch:
    types:
      - triggered-event
jobs:
  myEvent:
    runs-on: ubuntu-latest
    steps:
      # Runs a single command using the runners shell
      - name: Details of Event
        run: echo "REF=${{ github.event.client_payload.ref }} SHA=${{ github.event.client_payload.sha }} CONTENT=${{ github.event.client_payload.content }}" 

Tested in https://github.com/jimschubert/poc-triggered-workflow and https://github.com/jimschubert/poc-triggered-workflow-orchestrator

jimschubert avatar Mar 15 '20 01:03 jimschubert