Skip to content

[RELEASE] v1.4.2 (#50) #20

[RELEASE] v1.4.2 (#50)

[RELEASE] v1.4.2 (#50) #20

name: Build and Deploy
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-22.04
env:
CI: false
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.9.0'
- name: env setting
run: |
echo "${{ secrets.REACT_ENV_DEVELOPMENT }}" > .env
- name: Docker build and push
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb .
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# Stop and remove the existing container
docker stop thepopbusinessweb || true
docker rm thepopbusinessweb || true
# Remove the existing image
docker rmi ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb || true
# Copy Nginx configuration file
scp nginx.conf ubuntu@${{ secrets.HOST }}:/path/to/nginx.conf
# Build, push, pull and run the application container
docker build -t ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb .
docker push ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb
docker pull ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb
docker run -d -p 80:80 --name thepopbusinessweb ${{ secrets.DOCKER_USERNAME }}/thepopbusinessweb