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

Split repository secrets to variables in GH Actions #137

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tnevrlka
Copy link
Member

See individual commits for more details.

This PR is motivated by the need to expose some non-sensitive environment variables which were treated as secrets and thus masked with asterisks by GitHub in the GitHub Actions logs.

This is a problem in Jenkins too and will be addressed in another PR

@tnevrlka tnevrlka force-pushed the github-unmask-variables branch from c4e6504 to 0decbdb Compare February 26, 2025 14:38
@tnevrlka tnevrlka changed the title Split repository secrets to variables and secrets in GH Actions Split repository secrets to vars and secrets in GH Actions Feb 26, 2025
@tnevrlka tnevrlka changed the title Split repository secrets to vars and secrets in GH Actions Split repository secrets to variables in GH Actions Feb 26, 2025
if: '!isGitHub'

- name: QUAY_IO_CREDS_USR
if: '!isJenkins'
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about the various conditionals in this data file.

Do we need a better mechanism than isJenkins, isGitHub, isGitLab? Maybe a boolean that flags each as sensitive information?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm not the biggest fan of that too.
Took me a lot of time to understand why/how it works and it's pretty fragile:
When trying to render it locally, the state of the variables changes based on targetFile=<value> key-value pair where the value has to match this...Jenkins has to start with a capital J for some reason for example...

To be honest, I took all of it from the original data.yaml. I wasn't sure if I could come up with something different quick enough and not spend time that could be spent on the Azure DevOps pipelines effort instead

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to address this as part of this PR. We can come back to it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've re-read this thread and I believe that the isXXX mechanism is used as a workaround for various quirks of the different CI mechanisms - mainly for commenting out the variables.
The masked/unmasked logic should be handled by the split to xxx_secrets and xxx_variables where secrets should be masked and variables unmasked in all CIs.

@lcarva
Copy link
Member

lcarva commented Feb 26, 2025

Make sure you rebase. I just merged some updates to the konflux build pipeline that should fix the ec failure reported in the CI checks here.

@tnevrlka tnevrlka force-pushed the github-unmask-variables branch from 0decbdb to 10dae33 Compare February 26, 2025 20:37
@tnevrlka
Copy link
Member Author

By the way, merging this would break rhtap-e2e. If there will be no further comments, I will create a PR to change the test behavior

@lcarva lcarva marked this pull request as draft February 27, 2025 16:42
@lcarva
Copy link
Member

lcarva commented Feb 27, 2025

By the way, merging this would break rhtap-e2e. If there will be no further comments, I will create a PR to change the test behavior

Sounds good. Converted to draft to avoid an accidental merge. Post back here when things are ready.

ghub-set-vars currently sets every provided environment variable as a
repository secret.
GitHub automatically masks values of secrets with asterisks.

Some of the environment variables are not confidential and should
actually be shown to users.
This can be done by setting the environment variables as 'repository
variables' instead of 'repository secrets' in GitHub

Signed-off-by: Tomáš Nevrlka <[email protected]>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
All environment variables used for builds are currently stored under
the key 'build-secrets'
Some of the environment variables are not actually secret and should be
visible.

Differentiate the environment variables that are not secret by adding
them under a new key 'build_variables'

Do the same with 'gitops_secrets' and 'gitops_variables'

Signed-off-by: Tomáš Nevrlka <[email protected]>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
Previously, all environment variables were handled as secrets and
handled as such in CI workflow definitions.

Handle both variables and secrets in Jenkinsfile and GitHub Actions
workflow generation templates.
GitLab should not be affected due to a different way of handling
variables.

Signed-off-by: Tomáš Nevrlka <[email protected]>
@tnevrlka tnevrlka force-pushed the github-unmask-variables branch from db72ce8 to b3520c5 Compare March 25, 2025 15:29
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