Skip to content

Merge branch 'main' of https://github.com/van1164/video-streaming #72

Merge branch 'main' of https://github.com/van1164/video-streaming

Merge branch 'main' of https://github.com/van1164/video-streaming #72

Workflow file for this run

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
# Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시하는 과정
build-docker-image:
runs-on: ubuntu-latest
environment: video-share
steps:
- uses: actions/checkout@v3
# 1. Java 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# 2. Spring Boot 애플리케이션 빌드
- name: Build with Gradle
run: |
touch app/src/main/resources/application-oauth.properties
touch app/src/main/resources/application-prod.properties
touch app/src/main/resources/application.properties
echo "${{ secrets.APPLICATION_PROD }}" > app/src/main/resources/application-prod.properties
echo "${{ secrets.APPLICATION_OAUTH }}" > app/src/main/resources/application-oauth.properties
echo "${{ secrets.APPLICATION_PROPERTIES }}" > app/src/main/resources/application.properties
echo "${{ secrets.UTILL_APPLICATION_PROPERTIES }}" > util/src/main/resources/application.properties
cat util/src/main/resources/application.properties
chmod +x gradlew
./gradlew clean app:build --exclude-task test
ls
pwd
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/streaming:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/streaming:latest
cd live-streamming
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nginx-rtmp:ssl .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/nginx-rtmp:ssl
- name: Transfer files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: .
target: app
- name: SSH into EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd app
sudo docker compose down
sudo docker compose pull
sudo docker rm -f $(sudo docker ps -qa)
sudo cp -r ../video-streaming/data ./
pwd
ls
pwd
sudo docker pull van133/streaming
sudo docker pull van133/nginx-rtmp:ssl
#sudo docker-compose build
#sudo sh ./init-letsencrypt.sh
sudo docker compose up -d
sudo docker image prune --all --force