How to debug GitHub Actions workflow faster?
Asked Answered
S

4

6

I find it unproductive to edit yml file, then push a new commit again, and repeat the process hundreds of times until you make it right. I began thinking about how to automate this tedious process.

I tried GitHub Actions logging but doesn't help much.

Struve answered 11/3, 2023 at 13:40 Comment(0)
P
7

Install actionlint and nektos/act on your local machine.

  • Lint your workflow with actionlint. Fix issues if any.
  • After linting, run your workflow with act. Update your workflow if required and proceed accordingly.

If you're using VS Code then you can install Github Actions Locally extension. It's in its beta so proceed accordingly. It uses nektos/act under the hood.

Proleg answered 11/3, 2023 at 14:41 Comment(0)
G
2

Edit/Update:

GitHub just announced a VS Code extension which you can use.

Today, we’re excited to announce the release of the public beta of the official GitHub Actions VS Code extension. The extension provides support for authoring and editing workflows and helps you manage workflow runs without leaving your IDE.


In addition to Azeem's answer, you can install YAML extension for VSCode.

For Jetbrains' tools refer to this comment:

On the bottom right, click on "No JSON Schema"

enter image description here

Then choose "GitHub workflow"

enter image description here

Basically, you want that your IDE or text editor to load Github Actions' JSON schema.

Gittel answered 11/3, 2023 at 19:58 Comment(0)
L
1

mxschmitt/action-tmate lets you SSH into the runner by adding a step like

    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3

There is a roadmap item to add similar functionality natively in Q3 of 2023.

Layla answered 11/3, 2023 at 20:39 Comment(0)
T
0

You can use action-debug-vscode . It allows you to remotely access your github actions through browser based vs code.

Just add below line in your steps. A url to access vs code will be printed in your github actions logs

- uses: fawazahmed0/action-debug-vscode@main
Tribble answered 2/9, 2024 at 15:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.