|
| 1 | +name: Nats Blueprints CI and CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'nats/**' |
| 7 | + |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - 'nats/**' |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: code-runner |
| 15 | + BUILD_ARG_VERSION_NAME: NATS_SERVER_VERSION |
| 16 | +concurrency: |
| 17 | + group: nats-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + ci: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + nats_server_version: [2.10.0] |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Build nats:${{ matrix.nats_server_version }} image |
| 33 | + uses: ./.github/actions/docker-build |
| 34 | + with: |
| 35 | + context: ./nats |
| 36 | + dockerfile: ./nats/Dockerfile |
| 37 | + image-name: ${{ env.IMAGE_NAME }} |
| 38 | + tag: nats-${{ matrix.nats_server_version }} |
| 39 | + push: false |
| 40 | + container-registry: ${{ env.REGISTRY }} |
| 41 | + build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }} |
| 42 | + build-arg-version-value: ${{ matrix.nats_server_version }} |
| 43 | + |
| 44 | + cd: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }} |
| 48 | + |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + nats_server_version: [2.10.0] |
| 52 | + |
| 53 | + permissions: |
| 54 | + packages: write |
| 55 | + contents: read |
| 56 | + |
| 57 | + needs: |
| 58 | + - ci |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout code |
| 62 | + uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Build and push nats:${{ matrix.nats_server_version }} image |
| 65 | + uses: ./.github/actions/docker-build |
| 66 | + with: |
| 67 | + context: ./nats |
| 68 | + dockerfile: ./nats/Dockerfile |
| 69 | + image-name: ${{ env.IMAGE_NAME }} |
| 70 | + tag: nats-${{ matrix.nats_server_version }} |
| 71 | + push: true |
| 72 | + container-registry: ${{ env.REGISTRY }} |
| 73 | + container-registry-username: ${{ github.actor }} |
| 74 | + container-registry-password: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }} |
| 76 | + build-arg-version-value: ${{ matrix.nats_server_version }} |
0 commit comments