Update README.md #5
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
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: Install Gradle | |
run: | | |
cd ./Back-end | |
wget https://services.gradle.org/distributions/gradle-7.6.1-bin.zip | |
unzip -d $HOME/gradle gradle-7.6.1-bin.zip | |
echo "export PATH=\$HOME/gradle/gradle-7.6.1/bin:\$PATH" >> $HOME/.bashrc | |
source $HOME/.bashrc | |
- name: Build with Gradle | |
run: | | |
touch ./Back-end/src/main/resources/application.properties | |
echo "${{ secrets.APPLICATION_YAML }}" > ./Back-end/src/main/resources/application.yml | |
cat ./Back-end/src/main/resources/application.yml | |
cd ./Back-end | |
gradle clean build | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and push Docker image | |
run: | | |
cd ./Back-end | |
docker build -t shoeone/datebuzz-execute . | |
docker push shoeone/datebuzz-execute | |
- name: SSH and Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.REMOTE_SSH_KEY }} | |
script: | | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/authorized_keys | |
docker stop datebuzz-execute || true | |
docker rm datebuzz-execute || true | |
docker pull shoeone/datebuzz-execute | |
docker run -d -p 8080:8080 --name datebuzz-execute shoeone/datebuzz-execute |