I am new to actions.
I have an action that will start a node instance and build out javascript files when a PR is merged to master.
But sometimes there will be merges with no files to build, so I would like the action to check for files, and if there are none, just exit gracefully.
Right now I am doing this by setting an environment variable that every subsequent step checks, and it seems like there should be a better way. Anyone can tell me how I can stop all subsequent steps/jobs - is there some exit code that will stop everything but not throw an error?
name: Build to Site
on:
push:
branches:
- master
jobs:
job1:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check files
id: check_js_step
run: echo "::set-env name=HAS_FILES::$(find js -maxdepth 1 -type f)"
- name: Proceed with build?
if: ${{ env.HAS_FILES == '' }}
run: echo "::set-env name=YES_BUILD::1"
job2:
needs: [job1]
runs-on: macos-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
if: ${{ env.YES_BUILD == 1 }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
if: ${{ env.YES_BUILD == 1 }}
- name: Build project
if: ${{ env.YES_BUILD == 1 }}
run: yarn run build_js
- name: Move and name directory
if: ${{ env.YES_BUILD == 1 }}
run: cp -r build current