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

Provide env var to use gh CLI in GHA #3588

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

maximiliankolb
Copy link
Contributor

What changes are you introducing?

Provide env vars to use gh in GHA

Why are you introducing these changes? (Explanation, links to references, issues, etc.)

Original error message:

  Run gh run download '' -n pr
    gh run download '' -n pr
    shell: /usr/bin/bash -e {0}
  gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable. Example:
    env:
      GH_TOKEN: ${{ github.token }}

Anything else to add? (Considerations, potential downsides, alternative solutions you have explored, etc.)

Refs 71b5724 (PR 3587 on GitHub)

Checklists

  • I am okay with my commits getting squashed when you merge this PR.
  • I am familiar with the contributing guidelines.

no cherry-picks.

Comment on lines 10 to 11
env:
GH_TOKEN: ${{ github.token }}
Copy link
Member

Choose a reason for hiding this comment

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

From a security point of view I wonder if we should set this at the top level or not. I'd lean to being as specific as possible. @evgeni any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

That'd mean adding it to every run that has gh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we somehow use CODEOWNERS to prevent changes from non-maintainers in .github/* in PRs?

Applied in c4ffa1a

Copy link
Member

Choose a reason for hiding this comment

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

non-maintainers can't merge, so I think that's fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. But still a nice angle: PRs that change/introduce GHA that run on PRs and use that token. I can only hope it's similar to GitLab and tied to your user account.

Copy link
Member

Choose a reason for hiding this comment

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

That'd mean adding it to every run that has gh?

More that any npm package we happen to pull in via surge also can access the env var.

Original error message:
  Run gh run download '' -n pr
    gh run download '' -n pr
    shell: /usr/bin/bash -e {0}
  gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable. Example:
    env:
      GH_TOKEN: ${{ github.token }}

Refs 71b5724 (PR 3587 on GitHub)
@maximiliankolb maximiliankolb merged commit debb06a into theforeman:master Jan 17, 2025
8 checks passed
@maximiliankolb maximiliankolb deleted the provide_env_var branch January 17, 2025 13:49
@maximiliankolb
Copy link
Contributor Author

We are one step further: https://github.com/theforeman/foreman-documentation/actions/runs/12830400048/job/35778499772

Run unzip pr.zip
  unzip pr.zip
  shell: /usr/bin/bash -e {0}
unzip:  cannot find or open pr.zip, pr.zip.zip or pr.zip.ZIP.
Error: Process completed with exit code 9.

@evgeni
Copy link
Member

evgeni commented Jan 17, 2025

Ooooh, gh run download does unpack the artifact… handy?

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