Can I have multiple GitHub Actions workflow files?
You can have multiple files in the .github/workflows
folder. All files will be read and run as independent tests. The 'on' parameter on each file will tell when it must be called.
Following your idea you could have:
dev.workflow.yml
- To run some kind of testing maybe (only on dev branch, when push)
name: Dev Workflow - Test and check thing
on:
push:
branches:
- dev
jobs:
...
prod.workflow.yml
- To build and deploy your project (only on master branch, when a PR is closed)
name: Master Workflow - Build and deploy to production
on:
pull_request:
types: closed
branches:
- master
jobs:
...
Since this question was asked, GitHub has made a few changes to workflows. They are now written in YAML syntax rather than HCL, and instead of being stored in a .github/main.workflow
file, they are stored in a .github/workflows
directory. The documentation says that "You must store workflow files" (note the plural) "in the .github/workflows
directory of your repository."
So once you port your main.workflow
file to YAML syntax, you should be able to store each workflow in a single file the way you wanted.