fix: Align tagged todo detail actions #739
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: Dutypark CI/CD | |
| on: | |
| push: | |
| branches: [ "main", "stage" ] | |
| pull_request: | |
| branches: [ "main", "stage" ] | |
| types: [ opened, synchronize, reopened, ready_for_review ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| release-note: | |
| if: github.event_name == 'pull_request' && github.base_ref == 'main' && github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && !startsWith(github.event.pull_request.head.ref, 'dependabot/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Check PR release note entry | |
| run: node .github/scripts/check-pr-release-note.mjs "${{ github.event.pull_request.number }}" | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| working-directory: frontend | |
| - name: Validate release notes | |
| run: npm run release-notes:check | |
| working-directory: frontend | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| # Backend build | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Build backend with Gradle | |
| uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | |
| with: | |
| arguments: build | |
| # Frontend build | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| working-directory: frontend | |
| - name: Type check frontend | |
| run: npm run type-check | |
| working-directory: frontend | |
| - name: Build frontend | |
| run: npm run build | |
| working-directory: frontend | |
| # Upload artifacts | |
| - name: Upload backend artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-jar | |
| path: build/libs/*.jar | |
| - name: Upload frontend artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: frontend/dist | |
| deploy: | |
| needs: build | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stage') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download backend artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: backend-jar | |
| path: backend | |
| - name: Download frontend artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: frontend-dist | |
| - name: Setup SSH | |
| uses: webfactory/ssh-agent@v0.5.4 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Add remote server to known hosts | |
| run: | | |
| mkdir -p ~/.ssh | |
| ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_IP }} >> ~/.ssh/known_hosts | |
| - name: Deploy backend JAR | |
| run: scp -P ${{ secrets.SSH_PORT }} backend/*.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }}:/dutypark/download.jar | |
| - name: Deploy frontend dist | |
| run: | | |
| ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }} "rm -rf /dutypark/frontend-download && mkdir -p /dutypark/frontend-download" | |
| scp -r -P ${{ secrets.SSH_PORT }} frontend-dist/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }}:/dutypark/frontend-download/ | |
| - name: Execute remote commands | |
| run: | | |
| ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }} << 'EOF' | |
| mv /dutypark/download.jar /dutypark/build/libs/dutypark.jar | |
| rm -rf /dutypark/frontend/dist/* | |
| mv /dutypark/frontend-download/* /dutypark/frontend/dist/ | |
| docker compose -f /dutypark/docker-compose.yml build app | |
| docker compose -f /dutypark/docker-compose.yml up -d app nginx | |
| EOF |