Maven / GitHub Actions Interview Questions
What are steps, and what is the difference between run: and uses: in a step?
Steps are the individual tasks that make up a job. They run sequentially in the order listed, share the job's working directory and environment variables, and each step can read outputs produced by earlier steps. Every step has an optional name: for display in the logs and can set a conditional if: expression.
The two fundamental forms a step can take are run: and uses::
run:— Executes one or more shell commands directly on the runner. The default shell on Linux/macOS isbash; on Windows it ispwsh. You can override this withshell: pythonorshell: cmd. Userun:for any custom script, build command, or one-liner that does not need to be reused across repositories.uses:— References a pre-built action. The action can come from the GitHub Marketplace (actions/checkout@v4), another repository (org/repo@v1), a local path in the same repo (./my-action), or a Docker image (docker://alpine:3.19). Actions encapsulate reusable logic behind a stable interface with typed inputs and outputs.
steps:
- name: Checkout code
uses: actions/checkout@v4 # calls a reusable action
- name: Build project
run: ./gradlew build # runs a shell command
- name: Run custom script
run: |
echo "Multi-line"
echo "shell script"
shell: bash
A step cannot use both run: and uses: simultaneously — they are mutually exclusive. The key decision rule: reach for uses: when the task is a well-known, versioned operation (checkout, setup-node, docker-login); use run: for project-specific commands unique to your repo.
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...
