[Fix] Enforce project quota shrink against real usage #106
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: dc-api | |
| # Build, test, and publish the dc-api control-plane server image. Runs on | |
| # GitHub-hosted runners — | |
| # no self-hosted infrastructure needed. Deployment to a cluster is the | |
| # consumer's concern: their Flux ImageUpdateAutomation watches | |
| # ghcr.io/wso2/dc-api and rolls new tags into the cluster. | |
| on: | |
| pull_request: | |
| paths: | |
| - 'dc-api/**' | |
| - '.github/workflows/dc-api.yaml' | |
| push: | |
| branches: [controlplane] | |
| paths: | |
| - 'dc-api/**' | |
| - '.github/workflows/dc-api.yaml' | |
| workflow_dispatch: | |
| env: | |
| IMAGE: ghcr.io/wso2/dc-api | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: dc-api/go.mod | |
| cache-dependency-path: dc-api/go.sum | |
| - name: Unit tests | |
| run: cd dc-api && go test ./... | |
| build-and-push: | |
| # Only publish on push to controlplane (i.e. after a merge). PRs from | |
| # forks couldn't write to ghcr.io/wso2/* anyway — GITHUB_TOKEN's | |
| # packages:write permission is denied for fork-triggered runs. | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Generate a sortable timestamp tag (UTC) for Flux ImagePolicy's | |
| # numerical sort. See OCD's flux/platform/dc-api/base/image-automation.yaml | |
| # for the matching filter pattern. Bare-SHA tags sort alphabetically | |
| # which is meaningless for hex — picks "ff..." over every "fe...". | |
| - name: Generate build timestamp | |
| id: ts | |
| run: echo "tag=$(date -u +%Y%m%d-%H%M%S)" >> "$GITHUB_OUTPUT" | |
| - name: Build and push dc-api | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./dc-api | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE }}:latest | |
| ${{ env.IMAGE }}:${{ github.sha }} | |
| ${{ env.IMAGE }}:${{ steps.ts.outputs.tag }}-${{ github.sha }} | |
| cache-from: type=gha,scope=dc-api | |
| cache-to: type=gha,mode=max,scope=dc-api | |
| - name: Summary | |
| run: | | |
| { | |
| echo "### dc-api published" | |
| echo | |
| echo "- \`${{ env.IMAGE }}:latest\`" | |
| echo "- \`${{ env.IMAGE }}:${{ github.sha }}\`" | |
| echo | |
| echo "Consumer Flux ImagePolicy auto-bumps the deployed pin." | |
| } >> "$GITHUB_STEP_SUMMARY" |