Eric Leung Code and Data Learnings     about     blog     projects     misc     feed

Setup GitHub Actions to validate repository links

I think there’s a movement to move some continuous integration from Travis CI to GitHub Actions.

So here’s a post on how I converted one of my repositories, first by reviewing some of the GitHub interfaces and then creating it through the terminal.

So my repository awesome-nosql-guides has a tab labeled “Actions”.

Going there, you’re shown a screen talking about workflows here and there. If you haven’t set one of these up, this page should be mostly blank.

There is a handy workflow template that GitHub starts up for you if you click on “New Workflow”. Although it will be unaccessible for you, my new workflow link would look like this:

There is also a Quickstart for GitHub Actions available.

But going through and creating this workflow, I found this page “Workflow syntax for GitHub Actions” the most useful. The documentation is very clear on what is what once you get used to reading YAML syntax.

From the terminal, you’ll need to create a folder called workflows/ within the .github/ directory. If you’re in the root of your project, you can run this.

# Create folders and parent directories as needed
mkdir -p .github/workflows

Within the workflows/ directory, this is where you’ll create your workflows. Essentially, this is where all your translated .travis.yml configurations will go.

Here’s an annotated GitHub Action I set up.

# Name of your workflow that GitHub displays
name: Check Resources

# Name of GitHub event that activates the workflow (required)
on: [push,pull_request]

# List of jobs to be run for workflow
  # Name of job
    name: Validate links  # optional
    runs-on: ubuntu-latest  # type of machine to run on
      # These below are published Docker container images under `uses`
      - name: Checkout source files
        uses: actions/[email protected]

      - name: Setup Ruby 2.6
        uses: ruby/[email protected]
          ruby-version: 2.6

      # You can also run your custom commands if no published action exists
      - name: Run checks on links
        run: |
          gem install awesome_bot
          awesome_bot --allow-ssl --allow 302,429 --allow-dupe -f

Here is a list of operating systems you can place within jobs.<job_id>.runs-on option above.

You can take a look at more GitHub Actions on this Awesome-Actions page with a curated list of great things you can do with GitHub Actions. I hope to make use of this feature more in the future.