|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master"] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + packages: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + setup: |
| 14 | + name: Setup and Install |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 18 | + - name: Setup pnpm |
| 19 | + uses: ./.github/actions/setup-pnpm |
| 20 | + |
| 21 | + quality: |
| 22 | + name: Code Quality |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 26 | + - uses: biomejs/setup-biome@c016c38f26f2c4a6eb3662679143614a254263fd # v2 |
| 27 | + with: |
| 28 | + version: latest |
| 29 | + - run: biome ci . |
| 30 | + |
| 31 | + build: |
| 32 | + name: Build |
| 33 | + needs: setup |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 37 | + - uses: ./.github/actions/setup-pnpm |
| 38 | + - run: pnpm build |
| 39 | + |
| 40 | + test: |
| 41 | + name: Test |
| 42 | + needs: setup |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 46 | + - uses: ./.github/actions/setup-pnpm |
| 47 | + - run: pnpm test |
| 48 | + |
| 49 | + docker: |
| 50 | + name: Docker Build and Push |
| 51 | + needs: [build, test] |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 55 | + with: |
| 56 | + fetch-depth: 0 # Fetch all history for proper versioning |
| 57 | + # Set up Docker Buildx |
| 58 | + - name: Set up Docker Buildx |
| 59 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3 |
| 60 | + with: |
| 61 | + driver-opts: | |
| 62 | + image=moby/buildkit:v0.12.0 |
| 63 | + # Login to GitHub Container Registry |
| 64 | + - name: Login to GitHub Container Registry |
| 65 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 |
| 66 | + with: |
| 67 | + registry: ghcr.io |
| 68 | + username: ${{ github.actor }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + # Generate Docker metadata (tags, labels) |
| 71 | + - name: Docker metadata |
| 72 | + id: meta |
| 73 | + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5 |
| 74 | + with: |
| 75 | + images: ghcr.io/${{ github.repository }} |
| 76 | + tags: | |
| 77 | + type=raw,value=${{ github.sha }} |
| 78 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} |
| 79 | + type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} |
| 80 | + type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} |
| 81 | + type=ref,event=branch |
| 82 | + type=ref,event=pr |
| 83 | + type=sha,format=long |
| 84 | + # Build and push |
| 85 | + - name: Build and push |
| 86 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6 |
| 87 | + with: |
| 88 | + context: . |
| 89 | + push: ${{ github.event_name != 'pull_request' }} |
| 90 | + tags: ${{ steps.meta.outputs.tags }} |
| 91 | + labels: ${{ steps.meta.outputs.labels }} |
| 92 | + cache-from: type=gha |
| 93 | + cache-to: type=gha,mode=max |
| 94 | + |
| 95 | + summary: |
| 96 | + name: Workflow Summary |
| 97 | + needs: [setup, quality, build, test, docker] |
| 98 | + runs-on: ubuntu-latest |
| 99 | + if: always() # Run even if previous jobs fail |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 102 | + |
| 103 | + - name: Generate CI Summary |
| 104 | + run: | |
| 105 | + echo "# π CI Workflow Summary" >> $GITHUB_STEP_SUMMARY |
| 106 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 107 | +
|
| 108 | + # Build info |
| 109 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 110 | + echo "## π¨ Build Information" >> $GITHUB_STEP_SUMMARY |
| 111 | + echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY |
| 112 | + echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY |
| 113 | + echo "| **Repository** | ${{ github.repository }} |" >> $GITHUB_STEP_SUMMARY |
| 114 | + echo "| **Branch/Tag** | ${{ github.ref_name }} |" >> $GITHUB_STEP_SUMMARY |
| 115 | + echo "| **Commit** | [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |" >> $GITHUB_STEP_SUMMARY |
| 116 | + echo "| **Triggered by** | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY |
| 117 | + echo "| **Workflow Run** | [View Details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |" >> $GITHUB_STEP_SUMMARY |
| 118 | +
|
| 119 | + # Docker image info (when applicable) |
| 120 | + if [[ "${{ needs.docker.result }}" == "success" && "${{ github.event_name }}" != "pull_request" ]]; then |
| 121 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 122 | + echo "## π³ Docker Image" >> $GITHUB_STEP_SUMMARY |
| 123 | + echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY |
| 124 | + echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY |
| 125 | + echo "| **Repository** | ghcr.io/${{ github.repository }} |" >> $GITHUB_STEP_SUMMARY |
| 126 | + echo "| **Latest Tag** | ghcr.io/${{ github.repository }}:${{ github.sha }} |" >> $GITHUB_STEP_SUMMARY |
| 127 | + echo "| **Package URL** | [View on GitHub](https://github.com/${{ github.repository }}/pkgs/container/$(echo '${{ github.repository }}' | cut -d'/' -f2)) |" >> $GITHUB_STEP_SUMMARY |
| 128 | + fi |
0 commit comments