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

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

Top comments (0)