Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated sonarqube github action #529

Merged
merged 2 commits into from
Jan 2, 2024
Merged

Conversation

nithinputhenveettil
Copy link
Member

@nithinputhenveettil nithinputhenveettil commented Dec 26, 2023

Problem:

  • GitHub does not pass secrets to a runner if the pull request is from a forked repository. Consequently, our SonarQube action fails due to an invalid Sonar secret.

Proposed solution:

  • Split the SonarQube action into two separate actions:
  • The first action will handle the installation of dependencies and the execution of both unit and integration tests. After running the tests, this action will upload the results to an artifact. Notably, this action does not require any secrets, allowing it to succeed even for pull requests from forked repositories.
  • The second action will use the workflow_run trigger to initiate the action. This action will download the test cases from the previously generated artifact and update SonarQube accordingly.

Ref : Github Blog post.

A new trigger workflow_run was introduced to enable scenarios that require building the untrusted code and also need write permissions to update the PR with e.g. code coverage results or other test results. To do this in a secure manner, the untrusted code must be handled via the pull_request trigger so that it is isolated in an unprivileged environment. The workflow processing the PR should then store any results like code coverage or failed/passed tests in artifacts and exit. The following workflow then starts on workflow_run where it is granted write permission to the target repository and access to repository secrets, so that it can download the artifacts and make any necessary modifications to the repository or interact with third party services that require repository secrets (e.g. API tokens).

@nithinputhenveettil nithinputhenveettil changed the title change in sonarqube github action Updated sonarqube github action Dec 27, 2023
@nithinputhenveettil nithinputhenveettil marked this pull request as ready for review December 27, 2023 06:23
Copy link
Contributor

@sanojsubran sanojsubran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@nithinputhenveettil nithinputhenveettil merged commit 459d6a8 into main Jan 2, 2024
10 checks passed
@nithinputhenveettil nithinputhenveettil deleted the sonar-qube-action-update branch January 2, 2024 07:54
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.

3 participants