|
1 | 1 | name: 'diff-pr-management' |
2 | 2 | description: '差分があればPRを作り、差分がなければPRを閉じます' |
3 | 3 | inputs: |
4 | | - who-to-greet: # id of input |
5 | | - description: 'Who to greet' |
| 4 | + github-token: # id of input |
| 5 | + description: 'GITHUB_TOKEN' |
6 | 6 | required: true |
7 | | - default: 'World' |
8 | 7 | outputs: |
9 | 8 | random-number: |
10 | 9 | description: "Random number" |
11 | 10 | value: ${{ steps.random-number-generator.outputs.random-id }} |
12 | 11 | runs: |
13 | 12 | using: "composite" |
14 | 13 | steps: |
15 | | - # 差分があったときは差分を出力する |
16 | | - - name: Show diff |
17 | | - id: show_diff |
18 | | - run: | |
19 | | - echo "::set-output name=diff::$(git diff)" |
20 | 14 | # 差分があったときは、コミットを作りpushする |
21 | 15 | - name: Push |
22 | | - if: steps.show_diff.outputs.diff != '' |
23 | 16 | run: | |
24 | 17 | git config user.name "hatohakaraage" |
25 | 18 | git config user.email "hatohakaraage@example.com" |
26 | 19 | git add -u |
27 | 20 | git commit -m "鳩は唐揚げ!(自動で直してあげたよ!)" |
28 | | - git push -f https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:refs/heads/fix-text-${{github.event.pull_request.head.ref}} |
| 21 | + git push -f https://${{github.actor}}:${{inputs.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:refs/heads/fix-text-${{github.event.pull_request.head.ref}} |
| 22 | + shell: bash |
29 | 23 | # pushしたブランチでPRを作る |
30 | 24 | - name: Create PullRequest |
31 | 25 | uses: actions/github-script@v3 |
32 | | - if: steps.show_diff.outputs.diff != '' |
33 | 26 | with: |
34 | | - github-token: ${{secrets.GITHUB_TOKEN}} |
| 27 | + github-token: ${{inputs.GITHUB_TOKEN}} |
35 | 28 | script: | |
36 | 29 | const common_params = { |
37 | 30 | owner: context.repo.owner, |
@@ -71,12 +64,12 @@ runs: |
71 | 64 | }) |
72 | 65 | } |
73 | 66 | }) |
| 67 | + shell: bash |
74 | 68 | # 既にformat修正のPRがある状態で、手動でformatを修正した場合、format修正のPRを閉じる |
75 | 69 | - name: Close PullRequest |
76 | 70 | uses: actions/github-script@v3 |
77 | | - if: steps.show_diff.outputs.diff == '' |
78 | 71 | with: |
79 | | - github-token: ${{secrets.GITHUB_TOKEN}} |
| 72 | + github-token: ${{inputs.GITHUB_TOKEN}} |
80 | 73 | script: | |
81 | 74 | const head_name = "fix-text-${{github.event.pull_request.head.ref}}" |
82 | 75 | const common_params = { |
@@ -111,6 +104,7 @@ runs: |
111 | 104 | }) |
112 | 105 | } |
113 | 106 | }) |
| 107 | + shell: bash |
114 | 108 | - name: Exit |
115 | | - if: steps.show_diff.outputs.diff != '' |
116 | 109 | run: exit 1 |
| 110 | + shell: bash |
0 commit comments