Skip to content

Instantly share code, notes, and snippets.

@Rizary
Created August 25, 2023 11:47
Show Gist options
  • Save Rizary/e344b6973870c92891b13f23a1886e51 to your computer and use it in GitHub Desktop.
Save Rizary/e344b6973870c92891b13f23a1886e51 to your computer and use it in GitHub Desktop.
name: Deploy to Production
on:
workflow_dispatch:
release:
types: [created]
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker build . -f Dockerfile.production -t frontend:latest
name: Build the Docker image
- run: docker save frontend:latest | gzip > frontend.tar.gz
name: Save the Docker image
- name: Copy the saved Docker image
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
source: 'frontend.tar.gz'
target: '/home/dev/'
- uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
echo 'Removing container...'
docker container rm frontend -f &>/dev/null
echo 'Removing old image...'
docker image rm frontend -f &>/dev/null
echo 'Load new image...'
docker load < /home/dev/frontend.tar.gz
echo 'Run new image...'
docker run -d -p 3000:3000 --name frontend frontend:latest
echo 'Removing files...'
rm /home/dev/frontend.tar.gz
name: Deploy the sideloaded image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment