I have written a simple Github action to check to see if my linting rules have been met whenever a PR is raised. But whenever I run it, I get the error message "No jobs defined in jobs". How can I fix this?
name: Check rules
on:
pull_request:
branches:
- develop
- master
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '12'
check-latest: true
- run: npm install
- run: npm check-rules
As per the error message, you need to define jobs.
name: Check rules
on:
pull_request:
branches:
- develop
- master
jobs:
your_npm_job_name:
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '12'
check-latest: true
- run: npm install
- run: npm check-rules
Related
I would like to create a CI pipeline with GitHub Action but I have problems. The front end of the project is developed in Vue 3 and uses vitest to run the tests. It's in a folder called "WEB" in the root directory. So I would like to run my tests at each commit in the master branch but it returns this error:
Error: .github#L1
each step must define a `uses` or `run` key
I used the preexisting "Node.js" template and just added the "working-directory" property to specify the "WEB" folder.
Here is my ".yml" file
name: Runs frontend tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
working-directory: ./WEB
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Execute Unit tests
- run: npm ci
- run: npm run test
When you add a - it add an element at the steps array:
You should do it like this:
- name: Execute Unit tests
run: |
npm ci
npm run test
I am kinda new to github actions and I'm curious to know whether is it possible to trigger schedule job manually without duplicating the workflow yaml.
name: Build Automation
on:
workflow_dispatch
schedule:
- cron: 0 1 * * *
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2.5.0
- name: Dependency Installation
run: npm install
- name: Schedule Execution
uses: cypress-io/github-action#v4.2.0
with:
install: true
command: npm start
- name: Upload Test Artifacts
uses: actions/upload-artifact#v3.1.0
with:
name: dist
path: dist/
retention-days: 7
Workflow is missing a colon here
name: Build Automation
on:
workflow_dispatch:
schedule:
- cron: 0 1 * * *
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2.5.0
- name: Dependency Installation
run: npm install
- name: Schedule Execution
uses: cypress-io/github-action#v4.2.0
with:
install: true
command: npm start
- name: Upload Test Artifacts
uses: actions/upload-artifact#v3.1.0
with:
name: dist
path: dist/
retention-days: 7
Trying to make a CI pipeline that will bump root package.json and tag repo using a machine user access token, then have another workflow that triggers to make releases.
But currently, the release workflow never seems to fire.
Linke to a example repo https://github.com/labithiotis/ci-tag-release
I've noticed my PAT in github says it's never been used.
version.yml
name: Versioning
on:
workflow_run:
workflows: [CI]
branches: [main]
types:
- completed
jobs:
versioning:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Increment Versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Increment API version
uses: phips28/gh-action-bump-version#master
env:
GITHUB_TOKEN: ${{ secrets.HAL_PAT }}
with:
tag-prefix: v
release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
release:
name: Release Builds
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout#v2
- run: yarn
- run: yarn wsrun -p #kernel/plugin.main -m build
- name: Release Builds
uses: marvinpinto/action-automatic-releases#latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: *
I have two workflows, develop.yml and production.yml.
develop is configured to run on develop:
name: Develop
on:
push:
workflow_dispatch:
branches:
- develop
jobs:
perform-linting:
runs-on: windows-latest
steps:
- name: Checkout repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: "14.x"
- name: Install base dependencies
run: npm install
- name: Bootstrap
run: lerna bootstrap
- name: Run ESLint
run: lerna run lint
And production is configured to run on master:
name: Production
on:
push:
workflow_dispatch:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo code
uses: actions/checkout#v2
- name: Deploy to Heroku
uses: akhileshns/heroku-deploy#v3.12.12
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
heroku_email: ${{secrets.HEROKU_EMAIL}}
However, pushing changes to develop or master will trigger both of these workflows to run:
In the above scenario, why is production being run when I only pushed to develop?
your configuration effectively says 'run on all pushes, only allow manual dispatch on a particular branch' (though the latter isn't an option it seems).
You probably mean:
develop.yml
name: Develop
on:
push:
branches:
- develop
workflow_dispatch:
production.yml
name: Production
on:
push:
branches:
- master
workflow_dispatch:
My Rust repository containing multiple subfolders.I would like to be able to build and test each of the projects for each pull request or when a new code is pushed to the master. So I created a ci.sh. Performing the action, I get a "Can't open ./scripts/ci.sh" error.
I've checked that ci.sh has been added to the repo.
What's the proper way to designate ci.sh's path?
name: Rust
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Build, test, clippy all
# run: "${{ format('{0}/.github/scripts/ci.sh', github.workspace) }}" <-also can't find script
run: sh ./scripts/ci.sh
Directory Structure:
MY_EXAMPLES
- .github
- workflows
- scripts
- ci.sh
- build.yml
- EXAMPLE_1
- EXAMPLE_2
- EXAMPLE_3
I did the following and it worked.
echo hi > .github/workflows/scripts/ci.sh
name: test
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: test
run: sh .github/workflows/scripts/ci.sh