Skip to content

Merge pull request #47 from AkinariHex/nextjs #17

Merge pull request #47 from AkinariHex/nextjs

Merge pull request #47 from AkinariHex/nextjs #17

Workflow file for this run

name: Web deploy
on:
push:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: develop
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install
run: npm ci
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: develop
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: stagecodes
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -t stagecodes/otr-web-dev:latest .
docker push stagecodes/otr-web-dev:latest
deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: develop
- name: Create .env files
run: |
echo "${{ secrets.DEV_APP_ENV }}" > .env
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_SSH_HOST }}
username: ${{ secrets.DEV_SSH_USER }}
key: ${{ secrets.DEV_SSH_KEY }}
source: ".env"
target: "~/otr-web/"
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_SSH_HOST }}
username: ${{ secrets.DEV_SSH_USER }}
key: ${{ secrets.DEV_SSH_KEY }}
script: |
docker pull stagecodes/otr-web-dev:latest
docker stop otr-web-dev || true
docker rm otr-web-dev || true
docker run -d -p 3000:3000 --name otr-web-dev --env-file ~/otr-web/.env stagecodes/otr-web-dev:latest