以下の内容はhttps://pc.atsuhiro-me.net/entry/2023/12/01/215706より取得しました。


GitHub Actions でレポジトリを編集する

.github/workflows/run.yaml

on: push

permissions:
  contents: write
  
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: |
          echo "sample." >> text.txt
          git config user.name github-actions
          git config user.email github-actions@github.com
          git add .
          git commit -m "test"
          git push

解説

上記の例を実行すると,レポジトリのルートに text.txt という名前のファイルが作成され,github-actions というユーザーでレポジトリに追加されます.

GitHub Actions の実行環境に,contents: write 権限を付与します.権限がなければ以下のようにエラーとなります.

remote: Write access to repository not granted. fatal: unable to access 'https://github.com/***/***********/': The requested URL returned error: 403

Assigning permissions to jobs - GitHub Docs

メールアドレス

github-actions@github.com というメールアドレスが以下のドキュメントで使用されているので倣いました.実務上は問題なく動作しました.

GitHub - actions/checkout: Action for checking out a repo

ただし通常のユーザーと異なるようで,アイコンがなかったり詳細が表示されません.以下の issue で議論されていますが結論はでていないようです.

Set git user and email · Issue #13 · actions/checkout · GitHub




以上の内容はhttps://pc.atsuhiro-me.net/entry/2023/12/01/215706より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14