Skip to content

Testing workflow

Testing workflow #13

name: Deploying-Docker-image-to-AWS-EC2
on:
push:
branches:
- Feature-deploy-in-AWS
paths:
- "server/**"
defaults:
run:
working-directory: "server"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Docker Setup Buildx
uses: docker/[email protected]
- name: Install Dependencies
run: |
npm ci
- name: Verify Docker Setup
run: docker version
- name: Build and Push Docker Image
run: |
docker buildx create --use
docker build -t afsha9/video-storage-app:latest .
docker login -u afsha9 -p ${{ secrets.DOCKER_ACCESS_TOKEN }}
docker push afsha9/video-storage-app:latest
- name: EC2 SSH > Start PM2 process
uses: appleboy/[email protected]
with:
host: ${{ vars.EC2_HOST }}
username: ${{ vars.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker login -u afsha9 -p ${{ secrets.DOCKER_ACCESS_TOKEN }}
docker pull afsha9/video-storage-app:latest
docker stop $(docker ps -a -q)
docker run --rm -d -p 3000:3000 afsha9/video-storage-app:latest