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: Build VitePress Docs and Push to Harbor | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - develop | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/build-vitepress-docs.yml' | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: 'Docker image tag (default: latest)' | |
| required: false | |
| default: 'latest' | |
| env: | |
| HARBOR_REGISTRY: harbor.1cdevelopers.ru | |
| HARBOR_PROJECT: library | |
| IMAGE_NAME: integration-subsystem-docs | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.meta.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: docs/package-lock.json | |
| - name: Install dependencies | |
| working-directory: docs | |
| run: npm ci | |
| - name: Build VitePress documentation | |
| working-directory: docs | |
| run: npm run docs:build | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vitepress-dist | |
| path: docs/.vitepress/dist | |
| retention-days: 7 | |
| docker: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vitepress-dist | |
| path: docs/.vitepress/dist | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Harbor Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }} | |
| type=raw,value=${{ github.event.inputs.image_tag }},enable=${{ github.event_name == 'workflow_dispatch' }} | |
| type=sha,prefix=,format=short | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./docs | |
| file: ./docs/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| BUILD_DATE=${{ github.event.repository.updated_at }} | |
| VCS_REF=${{ github.sha }} | |
| - name: Generate SBOM | |
| uses: anchore/sbom-action@v0 | |
| with: | |
| image: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} | |
| format: spdx-json | |
| output-file: sbom.spdx.json | |
| - name: Upload SBOM artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sbom | |
| path: sbom.spdx.json | |
| retention-days: 30 | |
| trigger-deployment: | |
| needs: docker | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: Trigger ArgoCD deployment update | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.K8S_APPS_PAT }} | |
| repository: segate-k8s/integration-subsystem-docs | |
| event-type: image-updated | |
| client-payload: '{"sha": "${{ github.sha }}", "image_tag": "latest"}' | |
| notify: | |
| needs: [build, docker] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Notify on success | |
| if: ${{ needs.docker.result == 'success' }} | |
| run: | | |
| echo "✅ Documentation successfully built and pushed to Harbor" | |
| echo "Image: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}" | |
| - name: Notify on failure | |
| if: ${{ needs.docker.result == 'failure' }} | |
| run: | | |
| echo "❌ Failed to build or push documentation" | |
| exit 1 |