-
Notifications
You must be signed in to change notification settings - Fork 51
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
Automate opening a PR to update Swagger API doc by a workflow #804
Comments
[Pseudocode]
|
@computerphilosopher |
github workflow는 해본적이 없지만 Travis CI는 회사에서 써본 경험이 있습니다. 기본 구조는 비슷할테니 한 번 시도해보겠습니다. |
@computerphilosopher 하시면서 어려운 부분이 있으면 알려주세요~! (참고로 작성한 workflow의 테스트는 1차적으로는 본인의 forked repository에서 돌려보시면 될 것 같습니다. 권한 이슈로 upstream에서 바로 구동시킬 수는 없을 거예요.) @jihoon-seo 님~ |
/assign @computerphilosopher |
@hermitkim1 님~ 좋은 정보가 있으시면 여기 공유해주세요 ^^ |
reference 등을 한번 작성해 보겠습니다 😊
등을 참고하여.. [예시] (테스트 해 보지 않았습니다. 테스트가 필요합니다 😊) name: Open Swagger-doc-updating PR
on:
push:
branches:
- main
paths:
- 'src/core/**/**.go'
- 'src/api/rest/server/**/**.go'
jobs:
# The job key is "update-swagger-doc"
update-swagger-doc:
# Job name is "Update Swagger doc"
name: Update Swagger doc
# This job runs on Ubuntu-latest
runs-on: ubuntu-18.04
strategy:
matrix:
go-version: [ '1.17' ]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout source code
uses: actions/checkout@v2.3.4
- name: Install swag
run: |
go install github.com/swaggo/swag/cmd/swag@latest
- name: Update Swagger doc
run: |
cd src
make swag
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.UPDATE_SWAGGER_DOC_PAT }}
commit-message: Update Swagger REST API doc
committer: cb-bot <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: update-swagger-doc
base: main
delete-branch: true
title: '[Workflow] Update Swagger REST API doc'
body: |
Update Swagger REST API doc
- Updated with *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
swagger
automated pr
assignees: cloud-barista/cb-tumblebug-maintainer
reviewers: cloud-barista/cb-tumblebug-maintainer
team-reviewers: |
owners
maintainers
draft: false
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.create-pull-request.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pull-request.outputs.pull-request-url }}"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT" |
Forked repository에서 workflow를 테스트 해보실때 필요한 몇가지 정보(제가 이전에 삽질 했던... ㅠ)를 공유 드립니다.
PAT 설정시 체크해야하는 항목이 있었던것 같은데요. 추후에 공유 드리겠습니다~
|
현재 이슈 검토중입니다. 제시하신 파일에서는 make swag 명령어 적용 후 자동으로 Pull request를 여는 것으로 보이는데, 자동화된 변경사항이라 PR보다는 커밋을 바로 하는 편이 낫지 않을까요? 다음은 예시 action입니다. https://github.com/marketplace/actions/git-auto-commit https://github.com/marketplace/actions/add-commit |
@computerphilosopher 저는 바로 업스트림에 커밋하는 것 보다는 PR으로 여는 것을 선호합니다.. ^^ 하지만, 말씀하신 것과 같이, PR을 관리해야 하는 부담도 있긴 할 것 같습니다. 트레이드오프가 있네요. 제안해주신 방법으로 기여를 해주시면 될 것 같습니다..! |
컨트리뷰터는 소스코드에 API 관련 내용(struct, comment 등)을 수정한 경우,
make swag
을 통해 API 문서를 자동 생성하고 있습니다. 그리고 컨트리뷰터가 PR을 열어서 해당 파일을 업데이트하고 있습니다. (https://github.com/cloud-barista/cb-tumblebug/wiki/API-Document-Update)cb-tumblebug/src/api/rest/server/mcir/image.go
Line 12 in dc8e9e4
현재 이 과정(
make swag
또는swag init
)을 컨트리뷰터가 직접 수행하고 있는데, 다소 귀찮은 작업입니다. (API 수정에 대한 리뷰가 완료되었다면, 보통 자동 생성되는 문서에 대해서 따로 리뷰가 필요하지도 않습니다.)Workflow action을 추가하여 자동 처리되도록 만들 수 없을까요?
도움 주실 분~?
The text was updated successfully, but these errors were encountered: