Skip to content

Deploy

Deploy #39

Workflow file for this run

name: Deploy
run-name: Deploy
on:
push:
branches:
- develop
concurrency:
group: deploy-${{ github.ref_name }}
cancel-in-progress: true
env:
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/cokothon-idea-bank-backend:latest
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
run: git clone https://github.com/Black-White-Developer/2024-BW-server.git Backend
- name: Write config
run: |
echo "${{ secrets.AWS_YAML }}" > Backend/src/main/resources/config/aws.yaml
echo "${{ secrets.EMAIL_YAML }}" > Backend/src/main/resources/config/email.yaml
echo "${{ secrets.JWT_YAML }}" > Backend/src/main/resources/config/jwt.yaml
echo "${{ secrets.MONGO_YAML }}" > Backend/src/main/resources/config/mongo.yaml
echo "${{ secrets.REDIS_YAML }}" > Backend/src/main/resources/config/redis.yaml
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Image
uses: docker/build-push-action@v6
with:
context: Backend
push: true
platforms: linux/amd64
provenance: false
tags: ${{ env.IMAGE_NAME }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}-cache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}-cache
deploy:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
key: ${{ secrets.REMOTE_SSH_KEY }}
port: ${{ secrets.REMOTE_SSH_PORT }}
script: |
cd Backend
docker compose pull
docker compose up -d