LoginSignup
14
7

More than 3 years have passed since last update.

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

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

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