hato-botのCIを反映するよ! #5877
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
--- | |
name: pr-format | |
# pull_requestで何かあった時に起動する | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- closed | |
push: | |
branches: | |
- master | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
# PRが来たらformatをかけてみて、差分があればPRを作って、エラーで落ちるjob | |
pr-format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
with: | |
# ここでsubmodule持ってくるとdetached headにcommitして死ぬ | |
# submodule: 'recursive' | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up Python | |
uses: actions/[email protected] | |
id: setup_python | |
if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
with: | |
python-version-file: .python-version | |
cache: pipenv | |
- if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
run: sed -i -e "s/python_version = \".*\"/python_version = \"$(echo ${{ steps.setup_python.outputs.python-version }} | sed -e 's/\([0-9]*\.[0-9]*\).*/\1/g')\"/g" Pipfile | |
- name: Install pipenv | |
id: install_pipenv | |
continue-on-error: true | |
if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
run: bash "${GITHUB_WORKSPACE}/scripts/pr_format/pr_format/install_pipenv.sh" | |
- name: Install dependencies | |
if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
run: bash "${GITHUB_WORKSPACE}/scripts/pr_format/pr_format/pipenv_install.sh" | |
# formatする | |
# --exit-codeをつけることで、autopep8内でエラーが起きれば1、差分があれば2のエラーステータスコードが返ってくる。正常時は0が返る | |
- name: Format files | |
id: format | |
if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
run: bash "${GITHUB_WORKSPACE}/scripts/pr_format/pr_format/format.sh" | |
continue-on-error: true | |
- uses: dev-hato/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
branch-name-prefix: fix-format | |
pr-title-prefix: formatが間違ってたので直してあげたよ! | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true |