mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 12:33:17 +00:00
39 lines
1.0 KiB
YAML
39 lines
1.0 KiB
YAML
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
|