|
1 | | -name: CD - Docker Hub Publish |
| 1 | +name: CD - Container Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 | env: |
10 | 10 | BACKEND_IMAGE: jobhunter-backend |
11 | 11 | FRONTEND_IMAGE: jobhunter-frontend |
| 12 | + GHCR_NAMESPACE: jasontm17 |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
12 | 17 |
|
13 | 18 | jobs: |
14 | 19 | docker-hub-check: |
|
55 | 60 | echo "reason=credentials valid for Docker Hub pull,push" >> "$GITHUB_OUTPUT" |
56 | 61 | fi |
57 | 62 |
|
58 | | - publish: |
| 63 | + publish-docker-hub: |
59 | 64 | name: Publish to Docker Hub |
60 | 65 | runs-on: ubuntu-latest |
61 | 66 | needs: docker-hub-check |
@@ -148,6 +153,96 @@ jobs: |
148 | 153 | echo "Frontend image: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.FRONTEND_IMAGE }}" |
149 | 154 | echo "Tags: ${{ steps.meta-frontend.outputs.tags }}" |
150 | 155 |
|
| 156 | + publish-ghcr: |
| 157 | + name: Publish to GitHub Packages |
| 158 | + runs-on: ubuntu-latest |
| 159 | + if: >- |
| 160 | + github.event_name == 'push' && |
| 161 | + (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || |
| 162 | + startsWith(github.ref, 'refs/tags/v')) |
| 163 | +
|
| 164 | + steps: |
| 165 | + - name: Checkout |
| 166 | + uses: actions/checkout@v4 |
| 167 | + |
| 168 | + - name: Set up Docker Buildx |
| 169 | + uses: docker/setup-buildx-action@v3 |
| 170 | + |
| 171 | + - name: Login to GitHub Container Registry |
| 172 | + uses: docker/login-action@v3 |
| 173 | + with: |
| 174 | + registry: ghcr.io |
| 175 | + username: ${{ github.actor }} |
| 176 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 177 | + |
| 178 | + - name: GHCR metadata (backend) |
| 179 | + id: ghcr-meta-backend |
| 180 | + uses: docker/metadata-action@v5 |
| 181 | + with: |
| 182 | + images: ghcr.io/${{ env.GHCR_NAMESPACE }}/${{ env.BACKEND_IMAGE }} |
| 183 | + tags: | |
| 184 | + type=ref,event=branch |
| 185 | + type=semver,pattern={{version}} |
| 186 | + type=sha,prefix= |
| 187 | + flavor: | |
| 188 | + latest=true |
| 189 | + labels: | |
| 190 | + org.opencontainers.image.title=Jobhunter Backend API |
| 191 | + org.opencontainers.image.description=Spring Boot API for the Jobhunter IT recruitment platform with JWT auth, RBAC, Flyway migrations, MySQL, Actuator metrics, and local production observability. |
| 192 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 193 | + org.opencontainers.image.licenses=MIT |
| 194 | + org.opencontainers.image.vendor=Jobhunter |
| 195 | +
|
| 196 | + - name: GHCR metadata (frontend) |
| 197 | + id: ghcr-meta-frontend |
| 198 | + uses: docker/metadata-action@v5 |
| 199 | + with: |
| 200 | + images: ghcr.io/${{ env.GHCR_NAMESPACE }}/${{ env.FRONTEND_IMAGE }} |
| 201 | + tags: | |
| 202 | + type=ref,event=branch |
| 203 | + type=semver,pattern={{version}} |
| 204 | + type=sha,prefix= |
| 205 | + flavor: | |
| 206 | + latest=true |
| 207 | + labels: | |
| 208 | + org.opencontainers.image.title=Jobhunter Frontend Web |
| 209 | + org.opencontainers.image.description=Next.js frontend for the Jobhunter IT recruitment platform with responsive job search, candidate/recruiter/admin workspaces, E2E coverage, and visual regression. |
| 210 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 211 | + org.opencontainers.image.licenses=MIT |
| 212 | + org.opencontainers.image.vendor=Jobhunter |
| 213 | +
|
| 214 | + - name: Build and push backend to GHCR |
| 215 | + uses: docker/build-push-action@v6 |
| 216 | + with: |
| 217 | + context: ./backend |
| 218 | + push: true |
| 219 | + tags: ${{ steps.ghcr-meta-backend.outputs.tags }} |
| 220 | + labels: ${{ steps.ghcr-meta-backend.outputs.labels }} |
| 221 | + cache-from: type=gha |
| 222 | + cache-to: type=gha,mode=max |
| 223 | + provenance: true |
| 224 | + sbom: true |
| 225 | + |
| 226 | + - name: Build and push frontend to GHCR |
| 227 | + uses: docker/build-push-action@v6 |
| 228 | + with: |
| 229 | + context: ./frontend |
| 230 | + push: true |
| 231 | + tags: ${{ steps.ghcr-meta-frontend.outputs.tags }} |
| 232 | + labels: ${{ steps.ghcr-meta-frontend.outputs.labels }} |
| 233 | + cache-from: type=gha |
| 234 | + cache-to: type=gha,mode=max |
| 235 | + provenance: true |
| 236 | + sbom: true |
| 237 | + |
| 238 | + - name: GHCR summary |
| 239 | + run: | |
| 240 | + echo "## GitHub Packages" >> "$GITHUB_STEP_SUMMARY" |
| 241 | + echo "Backend tags:" >> "$GITHUB_STEP_SUMMARY" |
| 242 | + echo '${{ steps.ghcr-meta-backend.outputs.tags }}' >> "$GITHUB_STEP_SUMMARY" |
| 243 | + echo "Frontend tags:" >> "$GITHUB_STEP_SUMMARY" |
| 244 | + echo '${{ steps.ghcr-meta-frontend.outputs.tags }}' >> "$GITHUB_STEP_SUMMARY" |
| 245 | +
|
151 | 246 | verify-tag-build: |
152 | 247 | name: Verify tag Docker build |
153 | 248 | runs-on: ubuntu-latest |
|
0 commit comments