Skip to content

Commit

Permalink
chore(automation): test attempt to pass new API endpoints to generate…
Browse files Browse the repository at this point in the history
… workflow
  • Loading branch information
sanderblue committed Aug 28, 2024
1 parent 96f9661 commit 589161d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 33 deletions.
87 changes: 56 additions & 31 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,72 @@
name: Tutone Generate
on:
push:
branches:
- 'feat/automated-codegen'
workflow_dispatch:
inputs:
apiEndpoints:
required: true
type: string
description: 'The API endpoints for which to generate code'
workflow_call:
inputs:
apiEndpoints:
required: true
type: string
description: 'The API endpoints for which to generate code'

jobs:
createPullRequest:
generate:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
- name: Write temporary Tutone config file
uses: DamianReeves/write-file-action@master
with:
go-version: 1.21.x
path: .tutone.yml
contents: |
${{ inputs.apiEndpoints }}
write-mode: overwrite

- name: Add GOBIN to PATH
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Check config file contents
run: cat .tutone.yml
shell: bash

- name: Checkout code
uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: 1.21.x

- name: Set up git user
run: |
git config --global user.name nr-developer-toolkit
git config --global user.email [email protected]
# - name: Add GOBIN to PATH
# run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
# shell: bash

- name: Install Tutone
run: go install github.com/newrelic/tutone/cmd/tutone@latest
# - name: Checkout code
# uses: actions/checkout@v4

- name: Generate new code
run: make generate
env:
NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }}
# - name: Set up git user
# run: |
# git config --global user.name nr-developer-toolkit
# git config --global user.email [email protected]

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.DEV_TOOLKIT_TOKEN }}
commit-message: 'chore(tutone): update generated code'
signoff: false
branch: feat/generated-code
title: 'feat(codegen): generate code based on latest API changes'
body: |
Update generated code using Tutone
labels: |
enhancement
draft: true
# - name: Install Tutone
# run: go install github.com/newrelic/tutone/cmd/tutone@latest

# - name: Generate new code
# run: tutone generate
# env:
# NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }}

# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.DEV_TOOLKIT_TOKEN }}
# commit-message: 'chore(tutone): update generated code'
# signoff: false
# branch: feat/generated-code
# title: 'feat(codegen): generate code based on latest API changes'
# body: |
# Update generated code using Tutone
# labels: |
# enhancement
# draft: true
13 changes: 11 additions & 2 deletions .github/workflows/graphql-schema.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: NerdGraph Schema Diff
on:
push:
branches:
- 'feat/automated-codegen'
workflow_dispatch:
schedule:
# Cron executes at 0800, 1200, 1600 UTC (8am, 12pm, 4pm)
Expand Down Expand Up @@ -150,6 +153,12 @@ jobs:
if-no-files-found: error
overwrite: true

create-codegen-pr:
if: steps.schema-diff.outputs.hero_mention != ''
generate-code:
# if: steps.schema-diff.outputs.hero_mention != ''
uses: newrelic/newrelic-client-go/.github/workflows/generate.yml@main
with:
apiEndpoints: '[autoflowsDeleteWorkflowDefinition, autoflowsStopWorkflowRun, autoflowsUpdateWorkflowDefinition]'
secrets:
NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }}
DEV_TOOLKIT_TOKEN: ${{ secrets.DEV_TOOLKIT_TOKEN }}

0 comments on commit 589161d

Please sign in to comment.