Complete the code to install dependencies in a GitHub Actions workflow for an Express app.
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm [1]The npm install command installs all dependencies listed in package.json.
Complete the code to run tests in the GitHub Actions workflow.
steps:
- name: Run tests
run: npm [1]The npm test command runs the test scripts defined in package.json.
Fix the error in the deployment step to push the Docker image to Docker Hub.
steps: - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image run: | docker build -t myapp:[1] . docker push myapp:[1]
The tag latest is commonly used to mark the newest Docker image version.
Fill both blanks to create a GitHub Actions job that triggers on push to the main branch and sets up Node.js.
on:
push:
branches: [[1]]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: [2]The workflow triggers on pushes to the main branch and sets up Node.js version 18.
Fill all three blanks to define a Dockerfile that uses Node.js 18, copies app files, and runs the app.
FROM node:[1] WORKDIR /app COPY package*.json ./ RUN npm install COPY [2] ./ CMD ["node", "src/[3]"]
This Dockerfile uses Node.js 18, copies the src folder, and runs src/index.js to start the app.