Skip to content

generate-sdk

generate-sdk #25

Workflow file for this run

name: generate-sdk
on:
workflow_dispatch:
workflow_call:
inputs:
pr-base:
required: true
type: string
outputs:
pr-number:
description: pr number
value: ${{ jobs.generate-sdk.outputs.pr-number }}
permissions:
actions: read
contents: write
pull-requests: write
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
generate-sdk:
runs-on: ubuntu-latest
outputs:
pr-number: ${{ steps.create-pr.outputs.pull-request-number }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Determine base branch name
id: pr-base
run: |
if [[ "${{ github.event_name }}" = "issue_comment" ]]; then
echo "name=${{ inputs.pr-base }}" | tee -a "$GITHUB_OUTPUT"
else
echo "name=${{ github.ref_name }}" | tee -a "$GITHUB_OUTPUT"
fi
- name: Determine head branch name
id: pr-head
env:
BASE: ${{ steps.pr-base.outputs.name }}
run: |
DATE=$(date '+%s')
echo "name=gen/$BASE/$DATE" | tee -a "$GITHUB_OUTPUT"
- name: Re-generate SDKs
run: |
echo "::group::isp"
./run.sh
sudo chown -R $USER:$USER isp
echo "::endgroup::"
echo "::group::isp-slate"
./run-slate.sh
sudo chown -R $USER:$USER isp-slate
echo "::endgroup::"
- name: Detect generated changes
id: changes
run: |
git add .
git status -s
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
if: steps.changes.outputs.should-commit == 'true'
uses: peter-evans/create-pull-request@v6
with:
commit-message: "re-generate sdk"
branch: ${{ steps.pr-head.outputs.name }}
base: ${{ steps.pr-base.outputs.name }}
title: 'chore: bump sdk version'
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
- name: Print summary
if: steps.changes.outputs.should-commit == 'true'
env:
PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }}
PR_URL: ${{ steps.create-pr.outputs.pull-request-url }}
run: |
echo "Created [#${PR_NUMBER}](${PR_URL})" > "$GITHUB_STEP_SUMMARY"