はじめに
こんばんは。
とある案件で github action上で 別レポジトリをcloneして、もろもろ操作を行うというものがあったので、備忘録として残しておきます。
本題
対応した方法は以下
- name: Clone For Main Branch
uses: actions/checkout@v3
with:
repository: xxxxx/repo_a
token: ${{ secret.github_token }}
path: repo_a
fetch-depth: 0 ← depthは0指定
- name: Edit
run: |
cd ${{ github.workspace }}/repo_a
echo "edit..." >> edit.txt
- name: Commit
run: |
git config --local user.email "zzzzzz@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "edit"
- name: Push For Main
uses: ad-m/github-push-action@master
with:
branch: main
directory: ${{ github.workspace }}/repo_a
repository: xxxxx/repo_a
- name: Merge Branch Main -> Develop
run: |
cd ${{ github.workspace }}/repo_a
git checkout develop
git merge main
- name: Push For Develop
uses: ad-m/github-push-action@master
with:
branch: develop
directory: ${{ github.workspace }}/repo_a
repository: xxxxx/repo_a
無理やりやった感が強い...
以下の機能を使うことで、対象のレポジトリのworkflowを動かえせるようなのですが、僕の場合は403エラーでうまくいきませんでした...
personal access tokenも設定したのですが、うまく行かず...
終わりに
github action周りの話はこれでおしまいかも。
現場からは以上です。