|
| 1 | +name: build.docker.image.dev |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: |
| 5 | + - labeled |
| 6 | + workflow_dispatch: |
| 7 | + workflow_call: |
| 8 | + outputs: |
| 9 | + image_id: |
| 10 | + description: "ImageId of the docker image" |
| 11 | + value: ${{ jobs.build.outputs.image_id }} |
| 12 | + image_digest: |
| 13 | + description: "Digest of the image (sha256:xxx)" |
| 14 | + value: ${{ jobs.build.outputs.image_digest }} |
| 15 | + image_metadata: |
| 16 | + description: "Metadata as json" |
| 17 | + value: ${{ jobs.build.outputs.image_metadata }} |
| 18 | + image_version: |
| 19 | + description: "Version number of the Docker image" |
| 20 | + value: ${{ jobs.build.outputs.image_version }} |
| 21 | + |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + prepare: |
| 29 | + permissions: |
| 30 | + actions: read |
| 31 | + contents: write |
| 32 | + runs-on: [ self-hosted, linux, domain=sb ] |
| 33 | + outputs: |
| 34 | + image_version: ${{ steps.get_version.outputs.version }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + - uses: ./.github/actions/get_code_version |
| 40 | + id: get_version |
| 41 | + |
| 42 | + build: |
| 43 | + if: ${{ github.event.label.name == 'docker:build' || github.event_name == 'workflow_dispatch' }} |
| 44 | + needs: |
| 45 | + - prepare |
| 46 | + permissions: |
| 47 | + actions: read |
| 48 | + contents: read |
| 49 | + packages: write |
| 50 | + runs-on: [ self-hosted, linux, domain=sb ] |
| 51 | + outputs: |
| 52 | + image_id: ${{ steps.push.outputs.imageid }} |
| 53 | + image_digest: ${{ steps.push.outputs.digest }} |
| 54 | + image_metadata: ${{ steps.push.outputs.metadata }} |
| 55 | + image_version: ${{ needs.prepare.outputs.image_version }} |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Set up Docker Buildx |
| 60 | + uses: docker/setup-buildx-action@v3 |
| 61 | + |
| 62 | + - uses: coursier/setup-action@v1 |
| 63 | + with: |
| 64 | + jvm: corretto:11 |
| 65 | + apps: sbt |
| 66 | + |
| 67 | + - run: keytool -import -noprompt -trustcacerts -alias StrangeBeeCA -file /etc/ssl/certs/strangebee-sb-caroot.pem -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit || true |
| 68 | + |
| 69 | + - uses: actions/setup-node@v3 |
| 70 | + timeout-minutes: 15 |
| 71 | + continue-on-error: true |
| 72 | + with: |
| 73 | + node-version: 18.16 |
| 74 | + |
| 75 | + - name: Install bower |
| 76 | + run: npm install -g bower |
| 77 | + |
| 78 | + - name: Build packages |
| 79 | + run: sbt Docker/stage |
| 80 | + |
| 81 | + # I'm not really at ease with these tags |
| 82 | + # to me "latest" should be set manually, through a tag, for now |
| 83 | + # but further, it should "calculate" it, regarding the latest Docker image version available |
| 84 | + # for exemple if latest available is 3.2.0-1 and the sbt command returns 3.2.1-1, |
| 85 | + # then latest should apply |
| 86 | + # Moreover, the -1 is VERY important, because it increases with the number of builds: |
| 87 | + # - if a Docker image exists with tag 3.2.0-1, it should NOT be overidden but a new |
| 88 | + # 3.2.0-2 should be created, and the -1 cleaned up later |
| 89 | + ##### |
| 90 | + # TODO: work on tagging |
| 91 | + # |
| 92 | + # |
| 93 | + - name: Generate full docker tags |
| 94 | + id: meta |
| 95 | + uses: docker/metadata-action@v4 |
| 96 | + with: |
| 97 | + images: | |
| 98 | + name=${{ vars.SB_GHCR }}/cortex |
| 99 | + tags: | |
| 100 | + type=raw,value=devel |
| 101 | + type=raw,value=${{ needs.prepare.outputs.image_version }} |
| 102 | + labels: | |
| 103 | + org.opencontainers.image.title=cortex |
| 104 | + org.opencontainers.image.description=a Powerful Observable Analysis and Active Response Engine |
| 105 | + org.opencontainers.image.vendor=StrangeBee |
| 106 | + - name: Login to GitHub Container Registry |
| 107 | + uses: docker/login-action@v3 |
| 108 | + with: |
| 109 | + registry: ghcr.io |
| 110 | + username: ${{ github.actor }} |
| 111 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + |
| 113 | + - name: Build and push docker image |
| 114 | + uses: docker/build-push-action@v3 |
| 115 | + id: push |
| 116 | + with: |
| 117 | + context: target/docker/stage |
| 118 | + push: true |
| 119 | + platforms: linux/amd64,linux/arm64 |
| 120 | + tags: ${{ steps.meta.outputs.tags }} |
0 commit comments