What is the most likely reason the build step is skipped?
medium
A. The job name 'build' is reserved and cannot be used
B. The 'uses' action is outdated and blocks steps
C. The 'npm run build' command is invalid in React Native
D. The workflow file is missing the 'on' trigger section
Solution
Step 1: Check required sections in GitHub Actions workflow
Every workflow file needs an 'on' section to specify when it runs (e.g., on push or pull request). Without it, the workflow never triggers.
Step 2: Analyze given workflow
The workflow lacks the 'on' trigger, so GitHub Actions never starts the job and steps, causing the build step to be skipped.
Final Answer:
The workflow file is missing the 'on' trigger section -> Option D
Quick Check:
Missing 'on' = workflow never runs [OK]
Hint: Always include 'on' trigger in workflow files [OK]
Common Mistakes:
Thinking job names are restricted
Assuming outdated actions block steps
Believing npm build is invalid for React Native
5. You want to set up a CI/CD pipeline for your React Native app that runs tests on pushes to the main branch and deploys only when tests pass. Which GitHub Actions workflow snippet correctly implements this?
hard
A.
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: npm run test
deploy:
runs-on: ubuntu-latest
steps:
- run: npm run deploy
B.
on:
push:
branches:
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: npm run deploy
C.
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm run test
deploy:
needs: test
runs-on: ubuntu-latest
if: success()
steps:
- run: echo "Deploying app..."
D.
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: npm run deploy
Solution
Step 1: Identify trigger and branch conditions
The pipeline should trigger on pushes to the main branch only, so 'on: push: branches: - main' is correct.
Step 2: Ensure tests run before deploy and deploy depends on test success
Job 'deploy' depends on 'test' job with 'needs: test' and runs only if tests succeed using 'if: success()'.
Step 3: Verify steps in each job
'test' job installs dependencies and runs tests; 'deploy' job runs deployment commands after tests pass.
Final Answer:
The workflow that runs tests on main branch push and deploys only if tests pass -> Option C
Quick Check:
Test before deploy on main branch =
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm run test
deploy:
needs: test
runs-on: ubuntu-latest
if: success()
steps:
- run: echo "Deploying app..."
[OK]
Hint: Use 'needs' and 'if: success()' to chain jobs [OK]
Common Mistakes:
Deploying without waiting for tests
Triggering on wrong branches
Missing job dependencies
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.