Skip to content

Merge pull request #272 from boostcampwm-2024/prod-be #83

Merge pull request #272 from boostcampwm-2024/prod-be

Merge pull request #272 from boostcampwm-2024/prod-be #83

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- test-prod-be
jobs:
build:
name: Build, Test, and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies with Yarn
run: yarn install
- name: Build only backend package with Yarn
run: yarn build:be
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker compose -f be.build.yaml build
docker compose -f be.build.yaml push
env:
DOCKER_BUILDKIT: 1
- name: Execute deployment script on remote server
env:
SSH_PEM_KEY: ${{ secrets.SSH_PEM_KEY }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_PORT: ${{ secrets.SSH_PORT }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PEM_KEY" > ~/.ssh/SSH_PEM_KEY.pem
chmod 600 ~/.ssh/SSH_PEM_KEY.pem
ssh -p $SSH_PORT -i ~/.ssh/SSH_PEM_KEY.pem -o StrictHostKeyChecking=no [email protected] 'cd prod && bash prod_be.sh'