|
| 1 | +name: Build and Publish Docker Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + # github.repository_owner will evaluate to "Prescott-Data" (or whoever runs the action), matching ghcr.io/prescott/... |
| 14 | + # Note: The username needs to be lowercased for Docker tags, so we'll hardcode or use lowercase logic if needed. |
| 15 | + # Using github.repository is usually safer (e.g., prescott-data/nexus-framework), but your docs say `ghcr.io/prescott/...`. |
| 16 | + # Let's use the repository owner lowercase, but for exact match with docs: |
| 17 | + IMAGE_NAME_BROKER: ${{ github.repository_owner }}/nexus-broker |
| 18 | + IMAGE_NAME_GATEWAY: ${{ github.repository_owner }}/nexus-gateway |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-and-push-images: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + # Sets the permissions granted to the GITHUB_TOKEN for the actions in this job. |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + packages: write |
| 28 | + attestations: write |
| 29 | + id-token: write |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Docker Buildx |
| 36 | + uses: docker/setup-buildx-action@v3 |
| 37 | + |
| 38 | + - name: Log in to the Container registry |
| 39 | + uses: docker/login-action@v3 |
| 40 | + with: |
| 41 | + registry: ${{ env.REGISTRY }} |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + # --- Nexus Broker --- |
| 46 | + - name: Extract metadata (tags, labels) for Broker |
| 47 | + id: meta-broker |
| 48 | + uses: docker/metadata-action@v5 |
| 49 | + with: |
| 50 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BROKER }} |
| 51 | + tags: | |
| 52 | + type=raw,value=latest,enable={{is_default_branch}} |
| 53 | + type=semver,pattern={{version}} |
| 54 | + type=semver,pattern={{major}}.{{minor}} |
| 55 | +
|
| 56 | + - name: Build and push Broker Docker image |
| 57 | + id: push-broker |
| 58 | + uses: docker/build-push-action@v5 |
| 59 | + with: |
| 60 | + context: ./nexus-broker |
| 61 | + push: true |
| 62 | + tags: ${{ steps.meta-broker.outputs.tags }} |
| 63 | + labels: ${{ steps.meta-broker.outputs.labels }} |
| 64 | + |
| 65 | + # --- Nexus Gateway --- |
| 66 | + - name: Extract metadata (tags, labels) for Gateway |
| 67 | + id: meta-gateway |
| 68 | + uses: docker/metadata-action@v5 |
| 69 | + with: |
| 70 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GATEWAY }} |
| 71 | + tags: | |
| 72 | + type=raw,value=latest,enable={{is_default_branch}} |
| 73 | + type=semver,pattern={{version}} |
| 74 | + type=semver,pattern={{major}}.{{minor}} |
| 75 | +
|
| 76 | + - name: Build and push Gateway Docker image |
| 77 | + id: push-gateway |
| 78 | + uses: docker/build-push-action@v5 |
| 79 | + with: |
| 80 | + context: ./nexus-gateway |
| 81 | + push: true |
| 82 | + tags: ${{ steps.meta-gateway.outputs.tags }} |
| 83 | + labels: ${{ steps.meta-gateway.outputs.labels }} |
0 commit comments