ci: Update scala-cli version #22
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: Dashboard - Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'dashboard/**' | |
| - '.github/workflows/dashboard-deploy.yaml' | |
| pull_request: | |
| paths: | |
| - 'dashboard/**' | |
| - '.github/workflows/dashboard-deploy.yaml' | |
| workflow_dispatch: | |
| inputs: | |
| deploy_only: | |
| description: 'Skip build, only deploy existing image' | |
| type: boolean | |
| default: false | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: virtuslab/scala-community-build-dashboard | |
| jobs: | |
| test: | |
| if: ${{ !inputs.deploy_only }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: coursier/cache-action@v8 | |
| - uses: VirtusLab/scala-cli-setup@v1.12 | |
| - run: scala-cli test dashboard | |
| build: | |
| if: ${{ github.event_name != 'pull_request' && !inputs.deploy_only }} | |
| needs: [test] | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./dashboard | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Output image info | |
| run: | | |
| echo "### Dashboard Image Built :rocket:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY | |
| deploy: | |
| needs: [test, build] | |
| # Run when: build succeeded, OR deploy_only (skips both test and build) | |
| if: | | |
| always() && ( | |
| needs.build.result == 'success' || | |
| (inputs.deploy_only && needs.test.result == 'skipped' && needs.build.result == 'skipped') | |
| ) | |
| runs-on: ubuntu-22.04 | |
| environment: production | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: Set up kubectl | |
| uses: azure/setup-kubectl@v4 | |
| - name: Get AKS credentials | |
| run: | | |
| az aks get-credentials \ | |
| --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \ | |
| --name ${{ secrets.AZURE_AKS_CLUSTER }} \ | |
| --overwrite-existing | |
| - name: Deploy to AKS | |
| run: | | |
| # Apply deployment (uses latest tag) | |
| kubectl -n ${{ vars.CB_K8S_NAMESPACE }} apply -f k8s/dashboard.yaml | |
| # Force pull latest image | |
| kubectl -n ${{ vars.CB_K8S_NAMESPACE }} rollout restart deployment/dashboard | |
| - name: Wait for rollout | |
| run: | | |
| kubectl -n ${{ vars.CB_K8S_NAMESPACE }} rollout status deployment/dashboard --timeout=180s | |
| - name: Deployment summary | |
| run: | | |
| echo "### Dashboard Deployed :white_check_mark:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**URL:** https://scala3.westeurope.cloudapp.azure.com/dashboard" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY | |
| cleanup-registry: | |
| needs: [build] | |
| if: ${{ github.event_name != 'pull_request' && !inputs.deploy_only }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - uses: actions/delete-package-versions@v5 | |
| continue-on-error: true # Cleanup is best-effort, don't fail workflow | |
| with: | |
| owner: virtuslab | |
| package-name: scala-community-build-dashboard | |
| package-type: container | |
| min-versions-to-keep: 5 | |
| delete-only-untagged-versions: true |