Merge pull request #452 from pnu-code-place/release-1.3.7 #23
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: Continuous Integration to production registry and release (PROD) | |
| on: | |
| push: | |
| paths-ignore: | |
| - "deployment/**" | |
| - "scripts/**" | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| check-release-branch: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_release: ${{ steps.check_branch.outputs.is_release }} | |
| version: ${{ steps.extract_version.outputs.version }} | |
| steps: | |
| - name: Check if merged from release branch | |
| id: check_branch | |
| run: | | |
| commit_message="${{ github.event.head_commit.message }}" | |
| if [[ "$commit_message" =~ ^Merge\ pull\ request.*from.*release- ]]; then | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Extract version from merge commit message | |
| if: steps.check_branch.outputs.is_release == 'true' | |
| id: extract_version | |
| run: | | |
| VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP 'release-\K[0-9]+\.[0-9]+\.[0-9]+') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| detect-changes-by-component: | |
| needs: [check-release-branch] | |
| if: ${{ needs.check-release-branch.outputs.is_release == 'true' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| backend: ${{ steps.filter.outputs.backend }} | |
| frontend: ${{ steps.filter.outputs.frontend }} | |
| hub-auth: ${{ steps.filter.outputs.hub-auth }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: dorny/paths-filter@v2 | |
| id: filter | |
| with: | |
| base: "main" | |
| filters: | | |
| backend: | |
| - 'backend/**' | |
| frontend: | |
| - 'frontend/**' | |
| hub-auth: | |
| - 'hub/auth_server/**' | |
| ci-backend: | |
| needs: [detect-changes-by-component] | |
| if: ${{ needs.detect-changes-by-component.outputs.backend == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to Harbor | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ${{ secrets.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: ./backend | |
| file: ./backend/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-prod/backend:${{ github.sha }}-prod | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-prod/backend:latest | |
| ci-frontend: | |
| needs: [detect-changes-by-component] | |
| if: ${{ needs.detect-changes-by-component.outputs.frontend == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to Harbor | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ${{ secrets.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-prod/frontend:${{ github.sha }}-prod | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-prod/frontend:latest | |
| build-args: | | |
| SERVER_NAME=${{ secrets.PROD_SERVER_NAME }} | |
| APP_VERSION=${{ github.sha }} | |
| ci-hub-auth: | |
| needs: [detect-changes-by-component] | |
| if: ${{ needs.detect-changes-by-component.outputs.hub-auth == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to Harbor | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ${{ secrets.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: ./hub/auth_server | |
| file: ./hub/auth_server/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-hub/auth-server:${{ github.sha }} | |
| ${{ secrets.HARBOR_REGISTRY }}/code-place-hub/auth-server:latest | |
| create-release: | |
| needs: [check-release-branch, ci-frontend, ci-backend] | |
| if: | | |
| always() && | |
| needs.check-release-branch.outputs.is_release == 'true' && | |
| (needs.ci-frontend.result == 'success' || needs.ci-frontend.result == 'skipped') && | |
| (needs.ci-backend.result == 'success' || needs.ci-backend.result == 'skipped') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v2 | |
| - name: Debug Info | |
| run: | | |
| echo "Is Release: ${{ needs.check-release-branch.outputs.is_release }}" | |
| echo "Version: ${{ needs.check-release-branch.outputs.version }}" | |
| echo "CI Backend: ${{ needs.ci-backend.result }}" | |
| echo "CI Frontend: ${{ needs.ci-frontend.result }}" | |
| - name: Create Release | |
| if: needs.check-release-branch.outputs.version != '' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} | |
| with: | |
| tag_name: ${{ needs.check-release-branch.outputs.version }} | |
| release_name: Release ${{ needs.check-release-branch.outputs.version }} | |
| draft: false | |
| prerelease: false |