概要
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