Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create triggered workflow from openapi-generator releases #2

Open
jimschubert opened this issue Mar 1, 2020 · 1 comment
Open

Create triggered workflow from openapi-generator releases #2

jimschubert opened this issue Mar 1, 2020 · 1 comment

Comments

@jimschubert
Copy link
Member

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

@jimschubert
Copy link
Member Author

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/repository-dispatch@v1.0.0
      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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant