DEV Community

Dayzen
Dayzen

Posted on

2 1

Validate changed files

My Workflow

This Action is used to validate at every commit or pull request.

If you want to check to validate changed files on pushed at the master or on the pull request.

just add it in GitHub action steps like below.

Submission Category: Maintainer Must-Haves

Yaml File or Link to Code

name: 'build-test'
on:
  pull_request:
  push:
    branches:
      - "master"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm ci
      - uses: syeutyu/validate-changed-files@v1
        with:
          file-names: '["package.json", "READMD.md"]'
          github-token: {{ Token }}

Additional Resources / Info

Behind history

When I developed the custom service sdk of npm package
Sometimes I missing update package.json version

Then I merged after

umm...? why the sdk version is not changed?
Ahh... I missed upgrade version :(

So I created this GitHub action.

Describe of the repository

When you use a versioning system or package.

Some commit or pull request must need to include important file. (ex package.json or md file)

If you write not include file and after deployed? That's a very tiring situation.

So I want to prevent the above situation therefore just created this repo.

How to use

Just simple like below that.

name: 'build-test'
on:
  pull_request:
  push:
    branches:
      - "master"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm ci
      - uses: ./
        with:
          file-names: '["package.json", "READMD.md"]'
          github-token: {{ Token }}

The current Github action doesn't yet support an array type of input.

So I used some trick.

Just enclose an array string in quotation marks.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more