2020-09-17

Check out repository before using GitHub @actions/glob

github, actions, troubleshoot

banner

Image by Free-Photos from Pixabay


title: Check out repository before using GitHub @actions/glob date: "2020-09-17" published: true tags: "github, actions, troubleshoot" author: Sung M. Kim banner: ./images/featured-image.jpg bannerCredit: "Image by Free-Photos from Pixabay"

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, **.

1const glob = require("@actions/glob");2
3const globber = await glob.create("**");4const files = await globber.glob();5
6// files = []

Fix

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

e.g.)

1name: Report broken URLs2
3on: push4
5jobs:6  report_job:7    runs-on: ubuntu-latest8
9    steps:10      # 👇 Check out the repository11      # to be able to access the repository files12      # in "my_action"13      - name: Checkout repository14        uses: actions/checkout@v215
16      - name: Validate repository URLs and report broken link(s)17        uses: my_action@master

Image by Free-Photos from Pixabay