0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

サブディレクトリ上でGithubCLIのruby/setup-rubyを実行する方法

Posted at

動機

GithubCLIでRailsを動かす場合ruby/setup-rubyを使うが、これはトップディレクトリがRailsのディレクトリじゃないとエラーを吐く。

ディレクトリ構成は以下のようになっています。

- top
    - backend
        - app
        - bin
        - config
        ...
    - frontend

解決策

uses: ruby/setup-ruby@v1をする前にbackendディレクトリの中身をトップディレクトリに持ってきます。
以下の処理をuses: actions/checkout@v2uses: ruby/setup-ruby@v1の間に書いてください。

- name: Move to top directory
  env:
    SUB_DIR: backend
  run: |
    path=`pwd`
    mv $path/$SUB_DIR /tmp
    for dir in `find $path -maxdepth 0`
    do
      rm -rf $dir
    done
    for dir in `find /tmp/$SUB_DIR -maxdepth 0`
    do
      mv $dir $path
    done

backendディレクトリを/tmpに一旦移してカレントディレクトリの中身を全て削除し、/tmpに移した中身をカレントディレクトリに戻します。

おわり

かなり愚直なやり方になってしまったので、もっといい方法をご存知の方がおられたらコメントで指摘していただけると助かります。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?