Skip to content

Merge pull request #21 from catchroom/develop #35

Merge pull request #21 from catchroom/develop

Merge pull request #21 from catchroom/develop #35

Workflow file for this run

# github repository actions νŽ˜μ΄μ§€μ— λ‚˜νƒ€λ‚  이름
name: CI/CD using github actions & docker
# event trigger
# main λΈŒλžœμΉ˜μ— pushκ°€ λ˜μ—ˆμ„ λ•Œ μ‹€ν–‰
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Create application.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
cat ./src/main/resources/application.yml
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PWD }}
docker buildx build --push --platform linux/amd64 -t ${{ secrets.DOCKER_IMAGE_NAME }} .
# docker build -t ${{ secrets.DOCKER_IMAGE_NAME }} .
# docker push ${{ secrets.DOCKER_IMAGE_NAME }}
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_NAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker pull ${{ secrets.DOCKER_IMAGE_NAME }}
sudo docker stop chat-server
sudo docker run -d --rm --name chat-server -p 8080:8080 ${{ secrets.DOCKER_IMAGE_NAME }}