Skip to content

Conversation

@briantist
Copy link
Collaborator

With #21 landed, found a few issues:

  • if fails on forks (unless the wiki is enabled, and the actions/ and workflows/ directories existed in the repo)
  • the setting I was using for GH_NAME was wrong; it was supposed to be a username.

So this PR makes the following changes:

  • we set an env var SHOULD_RUN that checks whether we're running in the main repo, or whether a secret named GENERATE_WIKI_PAGES is set to yes
  • all steps in the job are now conditional, and only run if SHOULD_RUN is true
  • the Ansible role to generate the docs ensures the target directory exists
  • added .internal/ansible/** to the list of paths that trigger the workflow
  • [minor] moved adding the trailing forward slash on the wiki dir to the action invocation

So, on forks, this workflow will no longer fail. If you want it to run on your fork, you must enable the wiki, and you must set the secret in your fork.

Without the above, all of the job's steps will be skipped, however the job will still run (allocate a VM, build the action container, etc.). This is because we cannot use the secrets context nor the env context in the jobs.<job_id>.if conditional,s o there's no way we can use the secret trigger method AND skip the job as a whole.


Further thoughts: we might have more workflows (certain types of tests and other repo-level stuff, like maybe what @felixfontein proposed in #4 ), that should be opt-in or not run at all on forks. One way we can avoid putting the conditionals on every step, and instead use job-level conditionals, is to run a separate job that figures out the values, and sets outputs.

The jobs that need the information could use needs: to wait on that first job. I really don't like that pattern, but it's one of the only ways to get around some of the more frustrating limitations in GHA.

If we did that, we might consider a shared workflow for that initial fork-checking job, that way it can be re-used by this and future workflows.

Perhaps I will wait until the second workflow that needs this pattern before implementing this...

…generate/tasks/main.yml

Co-authored-by: Felix Fontein <felix@fontein.de>
@briantist briantist merged commit 3b383c7 into ansible-community:main Jan 17, 2022
@briantist briantist deleted the content-docs/generate-fixups branch January 17, 2022 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants