Reference stackoverflow post: https://stackoverflow.com/questions/49659880/circleci-v2-config-how-do-we-filter-by-owner-in-a-workflow
In the circleci version 1 config, there was the option to specify
owner as an option in a deployment. An example from the circleci docs ( https://circleci.com/docs/1.0/configuration/ ) with
owner: circleci being the key line:
deployment: master: branch: master owner: circleci commands: - ./deploy_master.sh
In version 2 of the config, there is the ability to use filters and tags to specify which branches are built, but I have yet to find (in the docs, or on the interwebs) anything that gives me the same capability.
What I'm trying to achieve is run build and test steps on forks, but only run the deploy steps if the repository owner is the main repo. Quite often people fork using the same branch name - in this case
master - so having a build fail due to an inability to deploy is counter-intuitive, especially as I would like to use a protected branch in git and only merge commits based on a successful build in a pull request.
I realise we could move to only running builds based on tags being present, but nothing is stopping somebody with a fork also creating a tag in their fork, which puts us back at square one.
This capability of v1 configs is missing in v2 workflows.
Putting in a bunch of if statements in the workflow commands is messy, and while it will do as a workaround, it would be good to have the capability in the v2 config in a cleaner/easier to understand way.
An example from the version 2 config document ( https://circleci.com/docs/2.0/workflows/ ).
workflows: version: 2 un-tagged-build: jobs: - build: filters: tags: ignore: /^v.*/ tagged-build: jobs: - build: filters: branches: ignore: /.*/ tags: only: /^v.*/