Maven / GitHub Actions Interview Questions
How is a GitHub Actions workflow file structured, and where must it be placed?
Every workflow file must be placed inside the .github/workflows/ directory at the root of your repository and must use the .yml or .yaml extension. GitHub automatically detects any file in that directory and registers it as a workflow.
The top-level keys of a workflow file are:
name:— A human-readable label shown in the GitHub UI (optional but recommended).on:— Declares the event(s) that trigger the workflow (required).env:— Workflow-level environment variables available to all jobs (optional).permissions:— Restricts whatGITHUB_TOKENcan do (optional, security best-practice).jobs:— A map of one or more named jobs (required).
A minimal but realistic example that checks out code and runs tests:
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
Each job under jobs: must declare runs-on: (the runner label), and then list its steps:. Step names are optional but make run logs much easier to read. YAML indentation is significant — use spaces, never tabs.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
