15
8

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

github actions で任意のブランチのみで job を実行する方法

15
Posted at

概要

github actions で 特定のブランチだけで実行したい特定の job があるときは、 on オプションでは対応しきれません。
なぜなら、 on オプションではワークフローの実行に対する条件だからです。

ref を参照して、 if を使う

master ブランチのみで実行する job の例
if: github.ref == 'refs/heads/master'

  production_deploy:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/master'
    steps:
      - name: Execute git checkout
        uses: actions/checkout@v2

参考記事
[GitHub Actions] branch conditional
https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/td-p/29794

15
8
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
15
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?