DEV Community

Cover image for Check out repository before using GitHub @actions/glob
Sung M. Kim
Sung M. Kim

Posted on β€’ Originally published at sung.codes on

3

Check out repository before using GitHub @actions/glob

TL;DR

Check out repository with actions/checkout@v2 before @actions/glob.

Introduction

The goal was to use GitHub JavaScript Action to validate URLs in a repostory.

Problem

The problem was that, @actions/glob library did not return any files even with a global matching pattern, **.

const glob = require("@actions/glob")

const globber = await glob.create("**")
const files = await globber.glob()

// files = []

Fix

To access the file in GitHub action, one needs to check out a repository to access files for.

e.g.)

name: Report broken URLs

on: push

jobs:
  report_job:
    runs-on: ubuntu-latest

    steps:
      # πŸ‘‡ Check out the repository
      # to be able to access the repository files
      # in "my_action"
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Validate repository URLs and report broken link(s)
        uses: my_action@master

Image by Free-Photos from Pixabay

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay