refactor project detail api #304
Workflow file for this run
This file contains hidden or 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
| name: Java CI with Gradle | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v3 | |
| with: | |
| cache-disabled: true | |
| # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | |
| - name: chmod | |
| run: chmod 777 ./gradlew | |
| - name: Clean and Build | |
| run: ./gradlew clean build | |
| - name: Build with Gradle Wrapper | |
| run: ./gradlew build | |
| - name: docker login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: repaire docker builder container driver | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| - name: docker image build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64,linux/aarch64 | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-springboot:latest | |
| # run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-springboot -f Dockerfile . | |
| # Step 7: Build Nginx image | |
| - name: Build Nginx Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: nginx/Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64,linux/aarch64 | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-nginx:latest | |
| # run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-nginx -f nginx/Dockerfile . | |
| ssh_raspberry: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: make docker-compose file | |
| env: | |
| PROJECT_DIR: /home/${{ secrets.RASPBERRY_USERNAME }}/withU | |
| # MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }} | |
| run: | | |
| envsubst < docker-compose.tpl.yml > docker-compose.yml | |
| - name: make nginx file | |
| env: | |
| PROJECT_DIR: /home/${{ secrets.RASPBERRY_USERNAME }}/withU | |
| SERVER_DOMAIN: ${{ secrets.RASPBERRY_HOST }} | |
| run: | | |
| envsubst '${SERVER_DOMAIN}' < nginx/nginx.tpl.conf > nginx.conf | |
| - name: scp | |
| uses: appleboy/scp-action@v0.1.6 | |
| with: | |
| host: ${{ secrets.RASPBERRY_HOST }} | |
| username: ${{ secrets.RASPBERRY_USERNAME }} | |
| password: ${{ secrets.RASPBERRY_PASSWORD }} | |
| port: 8082 | |
| source: docker-compose.yml, nginx.conf, nextlevel-nginx.conf | |
| target: "/home/${{ secrets.RASPBERRY_USERNAME }}/withU" | |
| - name: ssh | |
| uses: appleboy/ssh-action@v0.1.6 | |
| with: | |
| host: ${{ secrets.RASPBERRY_HOST }} | |
| username: ${{ secrets.RASPBERRY_USERNAME }} | |
| password: ${{ secrets.RASPBERRY_PASSWORD }} | |
| port: 8082 | |
| script: | | |
| chmod 777 /home/${{ secrets.RASPBERRY_USERNAME }}/withU/nextlevel-nginx.conf | |
| mv /home/${{ secrets.RASPBERRY_USERNAME }}/withU/nextlevel-nginx.conf /etc/nginx/conf.d | |
| docker stop springboot nginx | |
| docker rm springboot nginx | |
| docker rmi springboot | |
| docker rmi nginx | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-springboot:latest | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/nextlevel-nginx:latest | |
| cd /home/${{ secrets.RASPBERRY_USERNAME }}/withU | |
| docker compose up -d | |
| docker image prune -f |