|
| 1 | +name: CD INTERNAL DEV |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ develop ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + detect-changes: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + internal_changed: ${{ steps.filter.outputs.internal }} |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - id: filter |
| 15 | + uses: dorny/paths-filter@v3 |
| 16 | + with: |
| 17 | + base: develop |
| 18 | + filters: | |
| 19 | + internal: |
| 20 | + - 'internal/**' |
| 21 | +
|
| 22 | + build-internal: |
| 23 | + needs: detect-changes |
| 24 | + if: needs.detect-changes.outputs.internal_changed == 'true' |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - name: Set up JDK 17 |
| 29 | + uses: actions/setup-java@v4 |
| 30 | + with: |
| 31 | + distribution: 'corretto' |
| 32 | + java-version: '17' |
| 33 | + |
| 34 | + - name: Grant execute permission for gradlew |
| 35 | + run: chmod +x gradlew |
| 36 | + |
| 37 | + - name: Grant execute permission for run-test-mysql-redis.sh |
| 38 | + run: chmod +x run-test-mysql-redis.sh |
| 39 | + working-directory: ./domain |
| 40 | + |
| 41 | + - name: Run test mysql redis script |
| 42 | + run: ./run-test-mysql-redis.sh |
| 43 | + working-directory: ./domain |
| 44 | + |
| 45 | + - name: Test & Build internal only |
| 46 | + run: ./gradlew :internal:build |
| 47 | + |
| 48 | + - name: Sign in Dockerhub |
| 49 | + uses: docker/login-action@v3 |
| 50 | + with: |
| 51 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 52 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 53 | + |
| 54 | + - name: Build the Docker image |
| 55 | + run: docker build -f ./Dockerfile --platform linux/amd64 --no-cache -t samhap/kokomen-notification-internal:dev . |
| 56 | + working-directory: ./internal |
| 57 | + |
| 58 | + - name: Push the Docker Image to Dockerhub |
| 59 | + run: docker push samhap/kokomen-notification-internal:dev |
| 60 | + working-directory: ./internal |
| 61 | + |
| 62 | + deploy-internal: |
| 63 | + needs: build-internal |
| 64 | + runs-on: [ self-hosted, dev-notification ] |
| 65 | + steps: |
| 66 | + - name: Stop existing container |
| 67 | + run: sudo docker rm -f kokomen-notification-dev-internal || true |
| 68 | + |
| 69 | + - name: Remove old INTERNAL Docker image |
| 70 | + run: | |
| 71 | + if sudo docker images samhap/kokomen-notification-internal:dev -q | grep -q .; then |
| 72 | + sudo docker rmi -f samhap/kokomen-notification-internal:dev || true |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: pull docker compose yaml files |
| 76 | + working-directory: /home/ubuntu |
| 77 | + run: | |
| 78 | + [ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git |
| 79 | + cd kokomen-notification |
| 80 | + git sparse-checkout init --cone |
| 81 | + git fetch origin develop |
| 82 | + git checkout develop |
| 83 | + git sparse-checkout set docker/dev |
| 84 | + git pull origin develop |
| 85 | +
|
| 86 | + - name: Docker Image pull |
| 87 | + run: sudo docker pull samhap/kokomen-notification-internal:dev |
| 88 | + |
| 89 | + - name: Docker run |
| 90 | + working-directory: /home/ubuntu |
| 91 | + env: |
| 92 | + MYSQL_ROOT_PASSWORD_DEV: ${{ secrets.MYSQL_ROOT_PASSWORD_DEV }} |
| 93 | + SPRING_DATASOURCE_USERNAME_DEV: ${{ secrets.SPRING_DATASOURCE_USERNAME_DEV }} |
| 94 | + SPRING_DATASOURCE_PASSWORD_DEV: ${{ secrets.SPRING_DATASOURCE_PASSWORD_DEV }} |
| 95 | + run: | |
| 96 | + export HOSTNAME=$(hostname) |
| 97 | + cd kokomen-notification/docker/dev |
| 98 | + sudo -E docker compose -f docker-compose-dev.yml up -d kokomen-notification-dev-internal kokomen-notification-mysql-dev |
0 commit comments