現象
- secretsに,
ACCESS_TOKEN
を用意し,その中にPersonal GitHub tokenが入っています. - Github Actionsでの実行
yml
1name: correction_CALLED 2on: 3 workflow_dispatch: 4 issue_comment: 5 types: 6 - created 7 - edited 8 9jobs: 10 job_correction_CALLED: 11 if: (github.event.issue.pull_request != null) && github.event.comment.body == 'correction' 12 runs-on: ubuntu-latest 13 env: 14 # if DIFF_CHECK=0 then **/**.tex files was not changed by textlint. 15 DIFF_CHECK: 0 16 steps: 17 - name: Github-Script 18 uses: actions/github-script@v2 19 id: set-target-branch 20 with: 21 github-token: ${{ secrets.ACCESS_TOKEN }} 22 result-encoding: string 23 script: | 24 const pull_request = await github.pulls.get({ 25 owner: context.repo.owner, 26 repo: context.repo.repo, 27 pull_number: context.issue.number 28 }) 29 return pull_request.data.head.ref 30 31 - name: Checkout 32 uses: actions/checkout@v3 33 with: 34 ref: ${{ steps.set-target-branch.outputs.result }} 35 - name: Clone 36 uses: actions/checkout@v3 37 with: 38 repository: MIZOGUCHIKoki/ConfigFiles 39 path: ConfigFiles 40 - name: Copy files to current directory 41 run: | 42 cp ./ConfigFiles/tex_textlint/package.json ./ 43 cp ./ConfigFiles/tex_textlint/.textlintrc.json ./ 44 cp ./ConfigFiles/tex_textlint/package-lock.json ./ 45 cp ./ConfigFiles/.gitconfig ./ 46 47 - name: Setup-node 48 uses: actions/setup-node@v3 49 with: 50 node-version: 14 51 cache: 'npm' 52 - name: Install packages via packages.json 53 run: | 54 npm install 55 - name: Fix typo 56 run: | 57 npx textlint --fix **/**.tex 58 - name: Remove useless files 59 if: ${{ always() }} 60 run: | 61 rm -rf ConfigFiles node_modules package-lock.json package.json .textlintrc.json .gitconfig 62 - name: Check changed files 63 run: | 64 git diff >> diff.txt 65 if [ -s diff.txt ]; 66 then 67 echo "DIFF_CHECK=1" >> $GITHUB_ENV 68 fi 69 - name: Commit to current branch 70 if: ${{ env.DIFF_CHECK == 1 }} 71 run: | 72 git config user.name github-actions 73 git config user.email 41898282+github-actions[bot]@users.noreply.github.com 74 git commit -am "Proofreading" 75 - name: Push changes 76 uses: ad-m/github-push-action@master 77 with: 78 github_token: ${{ secrets.ACCESS_TOKEN }} 79 branch: ${{ steps.set-target-branch.outputs.result }}
でGithub上のPull RequestにCommit & Pushすると,Pullrequestに投稿されたら実行されるCIが動かなくなります.
- Push後に呼び出したいワークフローのトリガーは以下です
yml
1name: run-textlint 2on: 3 push: 4 branches: 5 - main 6 pull_request_target: 7 paths: 8 - '**/**.tex' 9略
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/02/21 13:42 編集