7 ms·
Work with GitHub Actions in Your Terminal with GitHub CLI
- petethepig 6y agoThe biggest problem with Actions that I see a lot of people struggle with is that you can’t easily debug things when they aren’t going well. I think they need to add some way for users to be able to ssh into the worker. Maybe each time an action step fails you have 5 mins to ssh into the container and inspect what’s going on.
- deleted 6y ago[deleted]
- trinovantes 6y agoYea setting up Actions is a pretty awful experience. I had to constantly git add, commit --amend, force push and retrigger the run and look at print statements.
- milliams 6y agoI really like that with GitLab you can run the CI script in a local container to debug things and then only commit and push once it's working.
- petethepig 6y agoThat's an even better solution.
- derefr 6y agoGitHub doesn't have exactly that, but it does have self-hosted workflow runners (which GitLab also has, as it happens.) If you run a local self-hosted runner, point your workflow at it, and trigger it (push/etc), then the job bounces from GitHub's backend over to your local runner, where you can then poke / prod / trace its execution. It's not quite as "safe" — you don't get to test the workflow in advance of deploying it, but rather have to test it by deploying it. But it's still pretty useful for debugging. You can e.g. set environment variables on the runner itself, that then propagate into the job, to see how they affect the job. Or change stuff in the runner's user's home directory until the job works, to figure out what the job needs there, rather than deploying over and over with different "tweak this file or that" steps.
- rvieira 6y agoI'm not that familiar with GH actions, but Sourcehut has a couple of pretty nice solutions for troubleshooting: (as you mentioned) time-limited SSH into the build server and a page to edit the manifest online and re-run without having to push anything.
- degraafc 6y agoI use tmate[1] to get a shell on the worker when I need to debug things interactively. Also act[2] lets you run a decent approximation of your actions locally. Still agree that it should be easier and not require third-party tools/actions, though. [1]: https://github.com/mxschmitt/action-tmate https://github.com/mxschmitt/action-tmate [2]: https://github.com/nektos/act https://github.com/nektos/act
- jrochkind1 6y agoaction-tmate... woah!
- karlicoss 6y agoYeah, the only downside of tmate is that you need to add/uncomment the line with it, push, then remove the commit again. It's much nicer in circleci, for example where you can simply rerun wish SSH in a button click. Even better would be if the VM was around for a bit after failing, so I could connect and inspect the state without rerunning at all.
- degraafc 6y agoYep, definitely agree. I feel like there are a lot of areas that GitHub Actions needs improvements to catch up to other CI providers, really basic-seeming stuff like "allow failure" support and so on.
- horse666 6y agoOne approach to avoid this karlicoss is to add a “workflow dispatch” section to the “on” events in the workflow: workflow_dispatch: inputs: debug_enabled: description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false Then under the job steps, make the debug step conditional on that optional flag: # Enable tmate debugging of manually-triggered workflows if the input option was provided - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} You then can just trigger the build on the required branch, setting debug_enabled to true and voila. Edit: but agree the CircleCI interface is nicer where you can just run a debug build with ssh access directly.
- deleted 6y ago[deleted]
- crazysim 6y agohttps://tunshell.com/ https://tunshell.com/ works great for *nix runners. I made https://github.com/nelsonjchen/reverse-rdp-windows-github-actions https://github.com/nelsonjchen/reverse-rdp-windows-github-ac... for the Windows runners. Just add continue on error to the failing step and use temporarily use these kinds of tools in the next step(s).
- kevincox 6y ago> https://tunshell.com/ https://tunshell.com/ works great for nix runners. Oh and their interface is a `curl | sh` that execs whatever happens to be lying around in `/tmp/tunshell/client`. I guess* that is probably fine on a single-user system but I prefer not to run binaries that just about every process on my system can write to. https://lets.tunshell.com/init.sh https://lets.tunshell.com/init.sh Edit: I filed a bug https://github.com/TimeToogo/tunshell/issues/19 https://github.com/TimeToogo/tunshell/issues/19
- derefr 6y ago> I guess that is probably fine on a single-user system Most of these services run your workload inside a container, so it's not even a single-user system; it's an ephemeral system. It's like anything's going to be there other than the base image + what you put there.
- kevincox 6y agoThis same script is used for the server and client. So you are running this on your workstation.
- kody 6y agoCircleCI lets you rerun a pipeline with ssh enabled so you can debug. It's helpful unless your failed step is at the end of a complex 20 minute deployment. I'll usually run my docker image locally, copy over the source, and run the pipeline by hand to debug, but then I have to set up all the environment variables that I get from CircleCI/Bitbucket Pipelines, and even then there's no guarantee that my local tests are identical to what I'm seeing in the pipeline (just today I hit a memory limit in Bitbucket pipelines that I couldn't recreate locally).
- Waterluvian 6y agoThe ability to ssh into the Travis VM and investigate the terminal state on failure is just amazing.
- seniorThrowaway 6y agoYou could create a self-hosted runner to test things out on. I'm not sure how hard it is to match Github's VM configuration but I don't think they veer far from the stock ubuntu config for instance.
- sbaildon 6y agoPost-fail ssh access is one of the headline features of https://builds.sr.ht https://builds.sr.ht
- ollien 6y agoI've used https://github.com/nektos/act https://github.com/nektos/act in the past. It works ok as long as you don't need artifacting.
- OJFord 6y agoI mostly struggle with the docs to be honest. But yeah, SSHing in is great. I miss that from Circle using GL & GH.
- jrochkind1 6y agoDo these CLI functions use public HTTP API that other tools could use for GH Actions?
- de-moray 6y agoI've implemented each of these features using public apis, so... Probably?
- wungsten 6y agoYes. You can authenticate "other tools" using a personal access token or GitHub App. https://docs.github.com/en/rest/reference/actions https://docs.github.com/en/rest/reference/actions
- OJFord 6y agoYes, when I requested notifications support in `gh` the response was basically 'yep we want to, but it's not stable API yet'.
- Waterluvian 6y agoAm I missing something obvious or do these kinds of systems lack a good story for testing? With Travis and now GH Actions I find the fastest way to develop is to just push countless commits and incrementally develop my work flow in a live-ish way while asking peers to ignore the email spam on failures.
- bellttyler 6y agoI do the same. Dozens of commits to get GH Actions working correctly.
- Waterluvian 6y agoI feel far better hearing a few people say they do it the same. It felt so wrong and amateur and kind of embarrassing.
- hctaw 6y agoIt doesn't help the yaml ui/ux is awful. - if ${{ github.event_name == 'why do you think this is acceptable?" }} run:| echo "I need programmatic CI no matter how much you think I don't" Just let us write our entire pipelines in typescript. People are already using Actions for bitcoin mining, hosting porn, or whatever - if I can do arbitrary shell stuff you're not making my life easier by putting it behind a yaml DSL pretending to be "no code." If it were just typescript with a reasonable library we could run and debug it locally without jumping through hoops. /rant
- rurban 6y agoI was using the beta gh actions support for a few months, and it was more stable than most comparable post-v1.0 tools. Cool blog post
- hctaw 6y agoCan I separate stdout/stderr logs and get it in order or is that broken on the gh CLI like on the web interface too
- diveanon 6y agoStill no way to test action locally. This is especially troublesome considering that some actions only take effect once you have merged them into master. So in order to develop an action that is using the on "delete" hook you need to disable CI on master, push your workflow to master, renable CI on master, switch to your dev branch and push a bunch of commits while iterating on your workflow. https://docs.github.com/en/actions/reference/events-that-trigger-workflows#delete https://docs.github.com/en/actions/reference/events-that-tri... Github what the fuck. Don't even get me started on the "master" -> "default" name change... "master" in the git context isn't even being used in the "master / slave" sense. Spend less time virtue signaling and improve your horrible CI and maybe I will consider bringing my projects back. For those of you who are going to recommend I try the "act" library, I have, and after hours of debugging esoteric errors I just gave up.
- pood 6y ago100% agree. I have a dummy/empty/stupid action that does nothing that I copy pasta in and out of all the time. I have another action/workflow that literally checks that the master dummy action always does nothing. GitHub actions is very lacking in docs and setting up your own runners is very prone to generating cryptic errors that only appear on self hosted runners and it only gets worse inside of docker land.
- nyellin 6y agoI've been playing with the idea of maintaining a repository of common dockerfiles, ci/cd pipelines, and kubernetes manifests with tooling for answering basic question about your app and then generating the skaffolding automatically. It would be kind of like backstage.io in this regard, but aimed at smaller companies that don't have dedicated platform teams. If anyone would use this, I would love to talk.
- WhyNotHugo 6y agoI'm honestly amazed at the popularity of GitHub Actions. This is probably the first time a proprietary Microsoft product *for developers* has had such huge popularity, even with many open source developers!