LoginSignup
13
4

More than 1 year has passed since last update.

【Github Actions】Githubの草を自動で生やす

Last updated at Posted at 2022-09-11

はじめに

今回は、Github Actionsを使い自動で草を生やす方法をご紹介します。

作業の流れ

リポジトリ作成

Githubにリポジトリを作ります。
Add a README file にチェックを入れてください。
スクリーンショット 2022-09-11 19.38.33.png

ymlファイル作成

リポジトリを作成したら Actions のページを開き、set up a workflow yourself をクリック。

スクリーンショット 2022-09-11 19.48.40.png

以下のコードを貼り付けます。

name: www

on:
  workflow_dispatch:

  schedule:
    - cron:  "0 0 * * *"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: "Run a generate www"
        run: |
          git config --global user.email ${{ secrets.USER_EMAIL }}
          git config --global user.name ${{ secrets.USER_NAME }}
          echo "w" >> README.md
          git add README.md
          git commit -m '[add] www'
          git push origin main

コードを変更できたら Start commit & Commit new file をクリック

スクリーンショット 2022-09-11 19.53.52.png

環境変数の設定

次に、作成したymlファイルの環境変数 USER_EMAILUSER_NAME を設定します。
Settings > Cecrets > Actions に移動。

  • USER_EMAIL :Githubに登録しているメールアドレス
  • USER_NAME :Github ID

スクリーンショット 2022-09-11 19.56.16.png

設定するとこんな感じです。

スクリーンショット 2022-09-11 19.57.13.png

actions実行

次に Actions に移動し、All workflowswww を選択し、Run workflow をクリックします。

スクリーンショット 2022-09-11 19.54.32.png

Actionsが実行され、成功すると緑のチェックマークがつきます。

スクリーンショット 2022-09-11 20.02.07.png

README に「w」がひとつ追加されていれば完成です!!!!

参考文献

13
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
4