-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Document how to use hub CLI on GitHub Actions #2249
Comments
Good idea. I haven't used hub from within Actions yet, so I'm summoning @bdougie @Geertvdc @rtimush @CLowenthal-zmi @LRWeber in case any of you have anything to add (but feel free to ignore). Off the top of my head, these are the steps that we'd need to document:
|
Hi @mislav, tnx for the mention. I'm the creator of the setup-hub action which installs the hub cli on your worker. https://github.com/marketplace/actions/setup-hub In that Readme it explains how to set it up. Basically you run the action to setup hub once once and afterwards you can just use it in your script steps. If any questions on this action let me know (it was the first github action I created) |
It may be worth noting; Since the recent GitHub Action workflow migration from HCL to YAML, we've been encountering authentication issues on our action's As a Docker container based action, the sudden change in behavior seems odd. I'm not sure if this is due to a coincidental change in how the provided (If anyone already has a working solution under the new YAML system, any advice would be appreciated! I've already sent a message to GitHub support to see if they can shed any light on this issue, but haven't heard back as yet.) |
@LRWeber is this what you are running into, Actions Event Restrictions? |
No, our issue is unrelated; We aren't trying to trigger anything else with the push from our action. Rather, we are just trying to get a push from our action to work at all! The error message we've been seeing is from the script that runs in our Docker action: This only started happening after we were forced to migrate our workflow from We have both |
@LRWeber I was able to solve this issue by creating a simple askpass.sh script and setting a |
@LRWeber Thanks for the information. I'm not entirely sure what changed here - I wouldn't have thought that there was anything in the git authentication model that we were doing special for HCL-based workflows that we've stopped doing in YAML based workflows. Independent of that, to get this working, you should be able to tell git to use the @bryanmacfarlane understands some of the tricky bits we do with git auth better than I do, he may have insight here on how to both specify this and do so in a way that is optimal for keeping the secrets secret. |
We have feature work in flight right now so What we currently do is use the extra header with the
That will work on hosted machines (single use) but be careful. We're about to release self hosted runners and remembering a token that's time bombed per run (which github token is) becomes problematic. The issues we've seen in CI are machines with cred managers where it asks you the first time but cred managers store and then the next run in a few hours on that machine fails because askpass isn't called. That's why we worked with git core to add the extra header option. The bearer token is passed for that invocation and never stored and doesn't trigger cred managers. Which is what you want in CI with time bombed tokens (the opposite of what you want on a dev machine with a long lived token). |
@bryanmacfarlane That's great news! It seems like a common use case, so that will be extremely helpful. If we don't make progress towards resolving our particular issue, we'll keep an eye out for that update.
I tried changing our push command to: We are tracking our specific issue here LLNL/llnl.github.io#43 (In case further discussion/troubleshooting would be more appropriate there instead!) |
In #2264 it was pointed out to me that none of the hub operations that hit the API (which is most of them) will work from Actions unless we change the hub codebase to send the Does this match other people's experience when trying to run |
I'm getting the same error with both name: No banned git tags
on:
push:
tags:
- hotfix
jobs:
delete:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v1
- name: Delete extra tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin "https://fregante:[email protected]/$GITHUB_REPOSITORY.git"
git push --delete origin hotfix EDIT: this is now available as an action: https://github.com/marketplace/actions/setup-git-token |
Just want to add that with hub version 2.12.4 I am still receiving the I was running to an extra annoying problem with an inner submodule which I was able to fix by applying @fregante's solution above. I've generalized that solution and added the lines for the submodule fix below:
|
@fregante @artificialsoph @bryanmacfarlane I wonder if, instead of rewriting git clone URLs to stick a token in them, one could create a netrc file as such: cat >>~/.netrc <<EOF
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF I haven't tried this, but there's a chance it might work and is probably cleaner. However, it seems that most people on this thread don't really have an issue with hub per se (i.e. with commands such as |
I had also tried adding I went through a few iterations and decided that adding a single line to re-set the Now I kinda wish GitHub would add offer a trusted action that includes that |
Adding It looks like our |
Just to clarify,
That's why my workflow above hardcodes the repo owner's username: you still have to provide it in the workflow somewhere. Alternatively, it can be extracted from echo "https://${GITHUB_REPOSITORY%/*}:$GITHUB_TOKEN@github.com" > ~/.git-credentials
git push Docs: EDIT: this is now available as an action: https://github.com/marketplace/actions/setup-git-token |
That's a good point. The new workflow authoring stopped enforcing that rule. Even when it did, we had been intentionally circumventing it to get I updated our code again, and I'm happy to say that all of our I am curious about the |
I think most of these scenarios will happen to work now but when we offer self-hosted runners later this year there will be problems with solutions that trigger the git auth flows leading to things like apple git storing a time bombed token, not challenging for auth again on the next job. The -c extra header thing is ugly but avoids all those problems. Also note that we have feature work that's almost done where push (to the triggering repo) will Haven't tried the netrc option. |
The user still has to provide the token via By the way, I packaged up the GIT credentials setup via steps:
- uses: actions/checkout@master
- uses: fregante/setup-git-token@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: git push ... # Or hub push if you use a container with hub Source at https://github.com/fregante/setup-git-token. No dependencies, just a handful of clear lines. |
…ues/2249\#issuecomment-527585430 Signed-off-by: Alexis Tyler <[email protected]>
This comment has been minimized.
This comment has been minimized.
@DrSensor - can you create a separate issue for getting the cli on the images? mention me and I'll get it routed to the compute team that creates the images. Include your wget workaround. Thanks! |
I requested adding |
@DrSensor Thank you for sharing your approach! I'm worried about downloading hub from a 3rd party: For the interest of security and stability, I would much rather suggest that people download hub from GitHub's own servers and to pin to a specific version of hub. Future major hub releases might change how To download hub for Linux and place the executable into wget -q -O- \
https://github.com/github/hub/releases/download/v2.12.8/hub-linux-amd64-2.12.8.tgz | \
tar xz --strip-components=1 --wildcards '*/bin/hub' |
@DrSensor and @mislav this is why i made the "setup-hub" Github Action to install the official hub cli from the latest release available. This way it is super easy to use it and is in line with other dependencies you need for your builds. You can use it as follows: steps:
- uses: actions/checkout@latest
- uses: geertvdc/setup-hub@master
- run: hub --version more info here: https://github.com/Geertvdc/setup-hub. or marketplace link: https://github.com/marketplace/actions/setup-hub Let me know if you have any feedback on this Action. Always open for it ❤️ |
I am actually a bit worried about GitHub action that is written in Javascript because there is a chance that the transitive dependencies might get compromised. That's why I'm using glare for temporary. Thanks @mislav for the input, I think I should host the proxy by myself or maybe use I hope published actions has something like manifest file for security permission. |
* ci: upload-artifact encoded dhall and its schema * ci: split job into build and publish * ci: move syntect/syntaxes.bin to syntect.packdump * ci: simplify hub.github.com installation from mislav/hub#2249 (comment) * ci: always download hub.github.com latest release also enable --wildcards on `tar` * ci: renew trigger definition since there is an update in workflow syntax docs https://help.github.com/en/articles/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet * ci: publish on tag
@DrSensor we do not pull dependencies at runtime by default so the potential for compromise with upstream dependencies for JavaScript is no different than any other packaging technology. Of course, someone could choose to do that using a docker container or Dockerfile but there is no way we can gruard against that. |
In
|
Here's a simple script to download hub for the current environment. curl -fsSL https://gist.github.com/mislav/941a4edd3b63c9d9b07f7901b27e8b23.txt | bash -s 2.12.8
bin/hub <command> It works on all Actions environments: Ubuntu, macOS, Windows. I'm considering "promoting" this script to the |
Note that the role of setup- actions is to ensure that all the actions configurations options just work by using a toolkit (e.g. proxies for self-hosted etc). It also ensures caching (self-hosted runners will only download once and continue to run other jobs.) and prepending the path for the next out of proc steps to reference as just The instructions here will download everytime correct? Another option is to offer setup-hub under the actions org so there is full chain of trust if that's your concern. I think we can also make auth "just work" similar to our checkout action. Push just works without having the user map anything. I would be open to that and help out if @Geertvdc is interested. Regarding security ... Setup actions do need the http-client dependency. actions -> tool-cache -> http-client The toolkit is maintained by github employees including the http client. Also note that recent releases has the http-client one we use completely under actions org locked down to GH employees. As @chrispat mentioned, it's a build time dependency (not runtime) so the actions are self contained. Once built, someone compromising a dependency will not affect existing actions. The http-client has one tiny external dependency (tunnel) which we (github) have inspected a part of our security audits. Our CI also runs audits. |
@bryanmacfarlane Thank you for the detailed explanation!
Correct. I thought this might be acceptable for casual usage for hub during an Action run.
That would be terrific. Please feel free to loop me into that work. (I suspect that will happen in the After other options are available, I will amend the documentation. |
@mislav - will do. Thanks! |
Apparently it should work now but it's not clear how to get there: #2149
Can you document it somewhere?
The text was updated successfully, but these errors were encountered: