Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
pr-base:
required: true
type: string
secrets:
ORG_ISP_WRITER_APP_ID:
required: true
ORG_ISP_WRITER_APP_PRIVATE_KEY:
required: true
outputs:
pr-number:
description: pr number
Expand All @@ -33,8 +38,15 @@ jobs:
pr-number: ${{ steps.create-pr.outputs.pull-request-number }}
steps:

- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.ORG_ISP_WRITER_APP_ID }}
private-key: ${{ secrets.ORG_ISP_WRITER_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
submodules: recursive

- name: Determine base branch name
Expand Down Expand Up @@ -66,28 +78,52 @@ jobs:
- name: Detect generated changes
id: changes
run: |
git add isp isp-slate isp-lifecycle
git status

if [ -n "$(git status -s)" ]; then
echo "should-commit=true" | tee -a "$GITHUB_OUTPUT"
else
echo "should-commit=false" | tee -a "$GITHUB_OUTPUT"
fi

- name: Create Pull Request
id: create-pr

- name: Create and push branch
if: steps.changes.outputs.should-commit == 'true'
uses: peter-evans/create-pull-request@v6
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b ${{ steps.pr-head.outputs.name }}
git push -u origin ${{ steps.pr-head.outputs.name }}

- name: Commit changes
if: steps.changes.outputs.should-commit == 'true'
uses: planetscale/[email protected]
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
with:
commit-message: "re-generate sdk"
commit_message: "re-generate sdk"
repo: ${{ github.repository }}
branch: ${{ steps.pr-head.outputs.name }}
base: ${{ steps.pr-base.outputs.name }}
title: 'chore: bump sdk version'
body: |
file_pattern: 'isp isp-slate isp-lifecycle'

- name: Create Pull Request
id: create-pr
if: steps.changes.outputs.should-commit == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
PR_BODY: |
Generated by [${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

Comment `recreate-me` on this pull request to have it closed and re-created
run: |
PR_URL=$(gh pr create \
--title "chore: bump sdk version" \
--body "$PR_BODY" \
--base ${{ steps.pr-base.outputs.name }} \
--head ${{ steps.pr-head.outputs.name }})

PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+$')
echo "pull-request-number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "pull-request-url=$PR_URL" >> "$GITHUB_OUTPUT"

- name: Print summary
if: steps.changes.outputs.should-commit == 'true'
Expand Down