LoginSignup
2
1

【GitHub Actions】 self-hosted runner実行後にnodeの依存関係・リポジトリデータをクリーンアップする

Posted at

概要

GitHub ActionsでNode.jsのプロジェクトを色々動かしていたら、self-hosted runnerとして使用していたEC2インスタンスがディスクフルになってしまったので、備忘録として残しておきます

リポジトリファイル・依存関係のクリーンアップ

jobs:
  workflow:
    runs-on:
      labels: [self-hosted, ec2-runner]
    steps:
      - name: checkout
        uses: actions/checkout@v3
      - name: Node Setup
        uses: actions/setup-node@v3.1.1
        with:
          node-version-file: ".node-version"
      - name: npm install -g yarn
        run: npm install -g yarn
      - name: yarn install # パッケージインストール
        run: yarn install
        
      - name: "リポジトリのデータをクリーンアップ"
        run: |
          ls -la ./
          rm -rf ./*
      - name: "yarnのキャッシュをクリアする"
        run: yarn cache clean

クリーンアップを実行しない場合・する場合の比較

クリーンアップを実行しない場合

$ cd actions-runner/_Work

$ du -d 1 -h
~~~
1.2G    ./github-repository
$ cd

$ du -d 1 -h
~~~
3.1G    ./.yarn

クリーンアップを実行した場合

$ cd actions-runner/_work

$ du -d 1 -h
~~~
900K    ./github-repository
$ cd ~

$ du -d 1 -h
~~~
0    ./.yarn

クリーンアップを実行することによって、ワークフロー実行時にクローンしたリポジトリのファイルデータやパッケージインストール時のキャッシュを削除できていることが確認できます。

2
1
0

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
2
1