This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
Add files via upload #202
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: Frontend Deployment | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build Main Branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v4 | |
- name: Adding secret | |
run: | | |
touch frontend2shine/.env | |
echo 'NEXTAUTH_URL= https://t2s.maiwald.cc' >> "frontend2shine/.env" | |
cat frontend2shine/.env | |
echo 'NEXTAUTH_SECRET= "${{secrets.NEXTAUTH_SECRET}}"' >> "frontend2shine/.env" | |
cat frontend2shine/.env | |
echo 'GITHUB_ID= "${{secrets.GH_ID}}"' >> "frontend2shine/.env" | |
cat frontend2shine/.env | |
echo 'GITHUB_SECRET= "${{secrets.GH_SECRET}}"' >> "frontend2shine/.env" | |
cat frontend2shine/.env | |
echo 'DATABASE_URL="postgresql://postgres:${{secrets.POSTGRES_PW}}@161.35.217.19:5432/users?schema=public"' >> "frontend2shine/.env" | |
cat frontend2shine/.env | |
- name: Build and Push Docker Image | |
uses: mr-smithers-excellent/docker-build-push@v6 | |
with: | |
image: techn1c/frontend2shine | |
tags: latest | |
registry: docker.io | |
directory: frontend2shine | |
dockerfile: frontend2shine/Dockerfile | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
deploy_to_droplet: | |
runs-on: ubuntu-latest | |
needs: build | |
name: Deploy to Digital Ocean Droplet | |
steps: | |
- name: Connect with SSH and Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
docker login | |
docker stop frontend2shine | |
docker remove frontend2shine | |
docker pull techn1c/frontend2shine:latest | |
docker run --name frontend2shine -p 80:3000 -d techn1c/frontend2shine:latest | |
docker stop frontend2shine | |
docker start frontend2shine |