Update nodejs.yml #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Build the application | |
run: npm run build | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Build Docker Image | |
run: | | |
docker build -t react-app . | |
- name: Log in to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Tag Docker image & Push | |
run: | | |
docker tag react-app:latest 211125436022.dkr.ecr.us-east-1.amazonaws.com/test:latest | |
docker push 211125436022.dkr.ecr.us-east-1.amazonaws.com/test:latest | |
- name: Deploy the application (optional) | |
run: | | |
echo "Deploying to production..." |