1
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 3 years have passed since last update.

GitHub Actions でファイルの存在チェックをして、存在しない時にエラーにする

Last updated at Posted at 2022-01-17

hashFiles存在しないファイルパスを渡すと空文字を返すので、 if でチェックして exit 1 すればいい。

.github/workflow/hoge.yml
name: hoge
on: workflow_dispatch
  inputs:
    deploy_env:
      description: deploy env
      required: true
# 省略..
jobs:
  some_job:
    runs_on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@2

      # 例えば環境変数ファイルを作る処理とかがこの辺に入る

      - name: File exists?
        if: ${{ hashFiles(format('.env.{0}', github.event.inputs.deploy_env)) == '' }}
        run: exit 1

と思ったけど普通に test すればいいだけか。。

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