質問編集履歴

6

target

2023/02/25 10:38

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
File without changes
test CHANGED
@@ -90,7 +90,7 @@
90
90
  push:
91
91
  branches:
92
92
  - main
93
- pull_request:
93
+ pull_request_target:
94
94
  paths:
95
95
  - '**/**.tex'
96
96
 

5

workflow

2023/02/22 12:16

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
File without changes
test CHANGED
@@ -83,6 +83,18 @@
83
83
  branch: ${{ steps.set-target-branch.outputs.result }}
84
84
  ```
85
85
  でGithub上のPull RequestにCommit & Pushすると,Pullrequestに投稿されたら実行されるCIが動かなくなります.
86
+ - Push後に呼び出したいワークフローのトリガーは以下です
87
+ ```yml
88
+ name: run-textlint
89
+ on:
90
+ push:
91
+ branches:
92
+ - main
93
+ pull_request:
94
+ paths:
95
+ - '**/**.tex'
96
+
97
+ ```
86
98
  - Github-ActionsからのPush前
87
99
  ![](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-21/318c5f7f-bf4b-4f0e-91f8-0fba8aec6410.png)
88
100
  - Github-ActionsからのPush後

4

image

2023/02/21 13:45

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
@@ -1 +1 @@
1
- Github actions アカウントからPullrequestにPushすると,CIが止まる(エラー?)
1
+ 『至急』Github actions アカウントからPullrequestにPushすると,CIが止まる(エラー?)
test CHANGED
@@ -87,3 +87,5 @@
87
87
  ![](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-21/318c5f7f-bf4b-4f0e-91f8-0fba8aec6410.png)
88
88
  - Github-ActionsからのPush後
89
89
  ![](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-21/66ca6d53-3e92-46b1-ba2d-f57938e65092.png)
90
+ - 再度,(Botでなくて)『私が』ファイルを編集し,コミットPushすると,CIが動き出します.
91
+ ![](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-21/875bc562-5e92-4867-9bab-b40b4a933798.png)

3

nitric

2023/02/21 13:42

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
File without changes
test CHANGED
@@ -73,8 +73,6 @@
73
73
  - name: Commit to current branch
74
74
  if: ${{ env.DIFF_CHECK == 1 }}
75
75
  run: |
76
- echo "machine github.com\nlogin MIZOGUCHIKoki\npassword ${{secrets.ACCESS_TOKEN}}" >> .netrc
77
- cat .netrc
78
76
  git config user.name github-actions
79
77
  git config user.email 41898282+github-actions[bot]@users.noreply.github.com
80
78
  git commit -am "Proofreading"

2

token

2023/02/21 13:41

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,5 @@
1
1
  ## 現象
2
+ - secretsに,`ACCESS_TOKEN`を用意し,その中にPersonal GitHub tokenが入っています.
2
3
  - Github Actionsでの実行
3
4
  ```yml
4
5
  name: correction_CALLED
@@ -7,6 +8,7 @@
7
8
  issue_comment:
8
9
  types:
9
10
  - created
11
+ - edited
10
12
 
11
13
  jobs:
12
14
  job_correction_CALLED:
@@ -68,13 +70,19 @@
68
70
  then
69
71
  echo "DIFF_CHECK=1" >> $GITHUB_ENV
70
72
  fi
71
- - name: Push to current branch
73
+ - name: Commit to current branch
72
74
  if: ${{ env.DIFF_CHECK == 1 }}
73
75
  run: |
76
+ echo "machine github.com\nlogin MIZOGUCHIKoki\npassword ${{secrets.ACCESS_TOKEN}}" >> .netrc
77
+ cat .netrc
74
78
  git config user.name github-actions
75
79
  git config user.email 41898282+github-actions[bot]@users.noreply.github.com
76
80
  git commit -am "Proofreading"
77
- git push origin HEAD
81
+ - name: Push changes
82
+ uses: ad-m/github-push-action@master
83
+ with:
84
+ github_token: ${{ secrets.ACCESS_TOKEN }}
85
+ branch: ${{ steps.set-target-branch.outputs.result }}
78
86
  ```
79
87
  でGithub上のPull RequestにCommit & Pushすると,Pullrequestに投稿されたら実行されるCIが動かなくなります.
80
88
  - Github-ActionsからのPush前

1

ソースコード

2023/02/21 08:22

投稿

K_Mizo
K_Mizo

スコア5

test CHANGED
File without changes
test CHANGED
@@ -1,10 +1,80 @@
1
1
  ## 現象
2
2
  - Github Actionsでの実行
3
3
  ```yml
4
+ name: correction_CALLED
5
+ on:
6
+ workflow_dispatch:
7
+ issue_comment:
8
+ types:
9
+ - created
10
+
11
+ jobs:
12
+ job_correction_CALLED:
13
+ if: (github.event.issue.pull_request != null) && github.event.comment.body == 'correction'
14
+ runs-on: ubuntu-latest
15
+ env:
16
+ # if DIFF_CHECK=0 then **/**.tex files was not changed by textlint.
17
+ DIFF_CHECK: 0
18
+ steps:
19
+ - name: Github-Script
20
+ uses: actions/github-script@v2
21
+ id: set-target-branch
22
+ with:
23
+ github-token: ${{ secrets.ACCESS_TOKEN }}
24
+ result-encoding: string
25
+ script: |
26
+ const pull_request = await github.pulls.get({
27
+ owner: context.repo.owner,
28
+ repo: context.repo.repo,
29
+ pull_number: context.issue.number
30
+ })
31
+ return pull_request.data.head.ref
32
+
33
+ - name: Checkout
34
+ uses: actions/checkout@v3
35
+ with:
36
+ ref: ${{ steps.set-target-branch.outputs.result }}
37
+ - name: Clone
38
+ uses: actions/checkout@v3
39
+ with:
40
+ repository: MIZOGUCHIKoki/ConfigFiles
41
+ path: ConfigFiles
42
+ - name: Copy files to current directory
43
+ run: |
44
+ cp ./ConfigFiles/tex_textlint/package.json ./
45
+ cp ./ConfigFiles/tex_textlint/.textlintrc.json ./
46
+ cp ./ConfigFiles/tex_textlint/package-lock.json ./
47
+ cp ./ConfigFiles/.gitconfig ./
48
+
49
+ - name: Setup-node
50
+ uses: actions/setup-node@v3
51
+ with:
52
+ node-version: 14
53
+ cache: 'npm'
54
+ - name: Install packages via packages.json
55
+ run: |
56
+ npm install
57
+ - name: Fix typo
58
+ run: |
59
+ npx textlint --fix **/**.tex
60
+ - name: Remove useless files
61
+ if: ${{ always() }}
62
+ run: |
63
+ rm -rf ConfigFiles node_modules package-lock.json package.json .textlintrc.json .gitconfig
64
+ - name: Check changed files
65
+ run: |
66
+ git diff >> diff.txt
67
+ if [ -s diff.txt ];
68
+ then
69
+ echo "DIFF_CHECK=1" >> $GITHUB_ENV
70
+ fi
71
+ - name: Push to current branch
72
+ if: ${{ env.DIFF_CHECK == 1 }}
73
+ run: |
4
- git config user.name github-actions
74
+ git config user.name github-actions
5
- git config user.email 41898282+github-actions[bot]@users.noreply.github.com
75
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
6
- git commit -am "Proofreading"
76
+ git commit -am "Proofreading"
7
- git push origin HEAD
77
+ git push origin HEAD
8
78
  ```
9
79
  でGithub上のPull RequestにCommit & Pushすると,Pullrequestに投稿されたら実行されるCIが動かなくなります.
10
80
  - Github-ActionsからのPush前