-
Notifications
You must be signed in to change notification settings - Fork 130
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
Setup workflows for OpenAPI code generation #366
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e62fc99
Add generate-code workflow #304 #346 #347
mokuzon be4b4ee
Fix renovate config for git submodule #361
mokuzon 18b3585
Add missing generating codes
mokuzon 94d0748
Remove unnecessary python setup
mokuzon 5ea1cb8
Sync https://github.com/line/line-bot-sdk-ruby/pull/405
mokuzon 1545dc0
Fix permission
mokuzon b11c995
Run pinact
mokuzon 285e549
Run generate-code.py
mokuzon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Generate OpenAPI based code | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
tests: | ||
name: Generate OpenAPI based code | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
# Setup | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
submodules: recursive | ||
- name: Update submodules | ||
run: git submodule update --remote --recursive | ||
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 | ||
id: setup_node_id | ||
with: | ||
node-version: 18 | ||
- name: Set up Java | ||
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
architecture: x64 | ||
|
||
# Generate codes | ||
- name: Generate code | ||
run: python3 generate-code.py | ||
- run: | | ||
diff=$(git --no-pager diff --name-only) | ||
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV | ||
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | ||
## Run if diff exists and pull request, and make CI status failure (but allow renovate bot) | ||
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' && github.actor != 'renovate[bot]' }} | ||
run: | | ||
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2 | ||
echo "The files with differences are as follows." >&2 | ||
echo "$(git --no-pager diff --name-only HEAD)" >&2 | ||
exit 1 | ||
## Run if diff exists and event is not pull request, and make PR | ||
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }} | ||
run: | | ||
# Determine Change Type via Submodule Script. This scripts read current uncommited changes. | ||
CHANGE_TYPE=$(npx zx ./line-openapi/tools/determine-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 ./line-openapi/tools/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="Codes are generated by openapi generator" | ||
BODY="⚠Reviewer: Please edit this description to include relevant information about the changes.⚠" | ||
fi | ||
|
||
# Create PR | ||
BRANCH_NAME="update-diff-${{ env.CURRENT_DATETIME }}" | ||
|
||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git checkout -b $BRANCH_NAME | ||
|
||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:recommended", | ||
"helpers:pinGitHubActionDigestsToSemver" | ||
], | ||
"timezone": "Asia/Tokyo", | ||
"automerge": true, | ||
"platformAutomerge": true, | ||
"git-submodules": { | ||
"enabled": true | ||
}, | ||
"labels": [ | ||
"dependency upgrade" | ||
], | ||
"packageRules": [ | ||
{ | ||
"matchPackagePatterns": [ | ||
"line-openapi" | ||
], | ||
"labels": [ | ||
"dependency upgrade", | ||
"line-openapi-update" | ||
], | ||
// In many cases, we would like to update line-openapi by dispatching the GitHub workflow during working | ||
// hours, as there are code changes. | ||
// If that is forgotten, there's a possibility that line-openapi updates or code changes won't happen at | ||
// all, so we allow it to run at night just in case. | ||
"schedule": [ | ||
"after 11pm", | ||
"before 4am" | ||
] | ||
}, | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add
explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1545dc0