forked from koluku/sudden-death
-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (56 loc) · 2.3 KB
/
pr-format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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: Get uv version
id: get_uv_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: echo "uv_version=$(sed -e 's/uv==//g' requirements.txt)" >> "$GITHUB_OUTPUT"
- name: Set up uv
uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
version: ${{steps.get_uv_version.outputs.uv_version}}
enable-cache: true
- name: Install dependencies
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/uv_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"
- uses: dev-hato/actions-diff-pr-management@8d475e5bc78f61c40024d4859b79134b66f788d2 # v1.2.1
if: success() || failure()
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