Skip to content

Workflow file for this run

name: Generate OpenAPI based code
on:
workflow_dispatch:
push:
branches:
- master
jobs:
tests:
name: Generate OpenAPI based code
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Update submodules
run: git submodule update --remote --recursive
- uses: actions/setup-node@v4
id: setup_node_id
with:
node-version: 18
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
architecture: x64
- name: Install Dependency
run: npm ci
# Generate codes
- run: |
python3 generate-code.py
- run: |
echo "a" > a.txt
diff=$(git --no-pager diff --name-only)
echo "DIFF_IS_EMPTY='false'" >> $GITHUB_ENV
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
run: |
# Determine Change Type via Submodule Script
CHANGE_TYPE=$(npx zx ./scripts/determin-change-type.mjs)
echo "Determined change type: $CHANGE_TYPE"
# Determine PR title and body
if [ "$CHANGE_TYPE" == "submodule-update" ]; then
# Fetch PR info from submodule
npx zx ./scripts/get-pr-info.mjs
PR_INFO=$(cat pr_info.json)
TITLE=$(echo "$PR_INFO" | jq -r '.title')
BODY=$(echo "$PR_INFO" | jq -r '.url')$'\n\n'$(echo "$PR_INFO" | jq -r '.body')
else
# Default PR title and body
TITLE="Code Update"
BODY="Reviewer: Please edit this description to include relevant information about the changes."
fi
BRANCH_NAME="update-diff-${{ env.CURRENT_DATETIME }}"
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b $BRANCH_NAME
#
git add a.txt
#
git add line-openapi
git add lib/**
git commit -m "Codes are generated by openapi"
git push origin $BRANCH_NAME
gh pr create -B ${{ github.ref_name }} -H $BRANCH_NAME -t "$TITLE" -b "$BODY" # --label "line-openapi-update"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}