[RELEASE]v1.2 (#30) #9
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: 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: 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 |