Update node.js.yml #16
This file contains 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: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install Dependencies | |
run: | | |
npm ci | |
docker-build: | |
runs-on: self-hosted | |
needs: build | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Build Docker Image | |
run: | | |
sudo docker build -t salman4425/instagram-frontend-fe:v1.0 . | |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker push salman4425/instagram-frontend-fe:v1.0 | |
deploy: | |
runs-on: self-hosted | |
needs: docker-build | |
steps: | |
- name: Deploy with Docker | |
run: | | |
sudo docker pull salman4425/instagram-frontend-fe:v1.0 | |
sudo docker run -d -p 3000:3001 --name instagram-frontend-fe-v1.0 salman4425/instagram-frontend-fe:v1.0 | |