Skip to content

Commit

Permalink
implement github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nheek committed Jan 28, 2024
1 parent efaa6a5 commit 3f20a3d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build, Push, and Deploy Docker Image

on:
push:
branches:
- main

jobs:
build-push-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Generate .env file
run: |
echo "NEXT_PUBLIC_OPEN_AI_API_KEY=${{ secrets.NEXT_PUBLIC_OPEN_AI_API_KEY }}" >> .env
- name: Build and Push Docker Image
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/motto:latest -f Dockerfile .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/motto:latest
- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/motto:latest
docker stop motto || true
docker rm motto || true
docker run -d --name motto -p 3001:3001 ${{ secrets.DOCKERHUB_USERNAME }}/motto:latest

0 comments on commit 3f20a3d

Please sign in to comment.