DevOps / Github Interview questions
What is the difference between "uses" and "run" in a GitHub Actions step?
run executes shell commands directly on the runner, the same as typing them into a terminal. uses invokes a pre-packaged, reusable action, either from the GitHub Marketplace, another repository, or a local path within the same repo, referenced by an owner/repo and version, like actions/checkout@v4.
steps: - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: npm install - name: Cache node modules uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }} - name: Run tests run: npm test
In short: reach for uses when a well-maintained action already does what you need (checking out code, setting up a language runtime, caching), and reach for run for anything project-specific that's just a shell command, like installing dependencies or executing your own test script.
More Related questions...