canonical / prometheus-juju-exporter

GNU General Public License v3.0
2 stars 8 forks source link

Enable CI for PRs from forked repo #6

Closed agileshaw closed 1 year ago

agileshaw commented 1 year ago

This PR updates the CI to address empty credential issue when opening PRs from an forked repo (example).

Github Action has workflow_run feature that runs a workflow "based on execution or completion of another workflow". Because the second workflow is triggered within the upstream repo, It is able to access secrets/tokens. In this case, CI tests is the first workflow. Upon its successful completion, SonarCloud workflow gets triggered and starts the execution.

One thing to note is that, because SonarCloud workflow is not initiated by a PR, it doesn't have the correct code coverage for scanning and analyzing. To workaround this issue, PR number and coverage report need to be recorded by the first workflow (CI Setup) and passed to the second (reference).

agileshaw commented 1 year ago

CI runs successfully when testing on my own fork repo (action history). Unfortunately I cannot test the SonarCloud workflow with this repo until PR gets merged because the second workflow needs to be present on main branch.

agileshaw commented 1 year ago

@esunar The reference to the discussion thread is in the PR description. I've traced their projects' workflow files, adopted and tweaked them to fit our needs.