mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 05:09:26 +00:00
add dockerfile and github actions workflow for deploy
This commit is contained in:
38
.github/workflows/deploy.yml
vendored
Normal file
38
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Deploy to DigitalOcean
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ershisan99/flashcards:latest
|
||||
|
||||
- name: SSH and Deploy to Droplet
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DROPLET_IP }}
|
||||
username: root
|
||||
password: ${{ secrets.SSH_PASSWORD }} # Using password instead of key
|
||||
script: |
|
||||
docker pull ershisan99/flashcards:latest
|
||||
docker stop flashcards || true
|
||||
docker rm flashcards || true
|
||||
docker run -d --name flashcards -p 80:3333 ershisan99/flashcards:latest
|
||||
Reference in New Issue
Block a user