Complete the code to define a basic GitHub Actions workflow that triggers on push.
name: Node.js CI
on: [1]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3pull_request instead of push triggers workflow on PRs, not pushes.The push event triggers the workflow when code is pushed to the repository.
Complete the code to add a step that installs Node.js dependencies using npm.
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm [1]npm start runs the app instead of installing packages.The npm install command installs all dependencies listed in package.json.
Fix the error in the step that runs tests by completing the command.
- name: Run tests
run: npm [1]npm build or npm start does not run tests.The npm test command runs the test scripts defined in package.json.
Fill both blanks to create a job that runs on Ubuntu and caches npm dependencies.
jobs:
build:
runs-on: [1]
steps:
- uses: actions/checkout@v3
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-[2]The job runs on Ubuntu latest version. The cache key includes Node.js version 18 to separate caches by version.
Fill all three blanks to define a workflow that triggers on pull requests, installs dependencies, and runs tests.
name: CI on: [1] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install dependencies run: npm [2] - name: Run tests run: npm [3]
push instead of pull_request for trigger.The workflow triggers on pull requests, installs dependencies with npm install, and runs tests with npm test.