Improve your workflow with 4 Actions of GitHub

Tram Ho

Here are four useful ways that GitHub helps improve your workflow.

If your code is hosted on Github, you can take advantage of the tasks that Github brings. Instead of running all tests and linters manually, we can take advantage of Github actions for these tasks.

Without any difficulties, here are 4 actions with Github that will save you time and improve your workflow. If you do not understand what Github actions are and how to use them, please stay here before proceeding with today’s article.

1. Check your website with Google Chrome’s Lighthouse Test

This action is a useful integration of Google’s Lighthouse Audit for websites, namely performance testing, accessibility, best practices, SEO and PWAs ( Progressive Web Application ).

Right now, the action will print five scores (within 100) of the output and upload the HTML and JSON versions of the report as evidence.

On the next release, this action will allow you to specify a threshold for each test and optionally not perform this step if they are not met.

Use

The following workflow performs a Lighthouse test on jarv.is , displays the five scores in the output of each step and uploads the results in .html and .json formats like the proof for download (like shown above).

Workflow.yml file:

Lighthouse is really helpful when you build PWAs. Project is inspired by GoogleChromeLabs / lighthousebot .

2. Run SSH commands with GitHub Actions

This action will run the argument provided as a command on your $ HOST via SSH. This is really useful if you want to run commands on your private server after every commit or push.

Use

To use this useful, just add the following lines to .github/main.workflow

Argument requirements

The argument you will use is the command that will be run on your server via SSH.

For example

  • args = "/opt/deploy/run"
  • args = "touch ~/.reload"

Security requirements

You need to provide some confidential information to use actions:

  • PRIVATE_KEY : Your private SSH key.
  • HOST : The action host will SSH to run the command. For example, your.site.com .
  • USER : SSH command users will authenticate as with the private key.

You can see the details at the Github repository .

3. Detect leak of secret keys – gitleaks-action

Git checks the secret commit with gitleaks

Use

Credibility from zricethezav / gitleaks for complex bits.

4. GitHub Action runs ESLint

This action executes the ESLint emulator on specified JavaScript files without any previous actions / build or Docker steps.

You must have ESLint running local for actions to be executed. It will use the same rules as you do locally. You can find more information at the ESLint getting started guide .

Use

Here is an example to make it work:

By default, it will run ESLint through all files in the project. But you can also specify a range of files on arguments, like ESLint:

If not ̀ need any installation step before installing the module, actions will perform yarn install or npm install automatically.

Conclusion

I hope you have learned something new from your writing. If there are any Github Actions you know, share them to make the most of Github’s benefits.

Source : Improve Your Workflow With These 4 GitHub Actions

Share the news now

Source : Viblo