|
16 | 16 | name: Check code is formatted with ktlint |
17 | 17 | uses: ./.github/workflows/ktlint.yml |
18 | 18 |
|
19 | | - publish_docker_image_to_docker_hub: |
20 | | - needs: |
21 | | - - run_unit_tests |
22 | | - - check_code_formatting |
23 | | - name: Build & Push docker image to dockerhub |
24 | | - runs-on: ubuntu-24.04 |
25 | | - steps: |
26 | | - - name: Checkout code |
27 | | - uses: actions/checkout@v4 |
28 | | - |
29 | | - - name: Extract metadata to env variables |
30 | | - uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1 |
31 | | - |
32 | | - - name: Pull previous image to support caching |
33 | | - run: docker pull $IMAGE_NAME:builder || echo "Previous builder image not found" |
34 | | - |
35 | | - - name: Build dependencies & source code into builder image to support caching |
36 | | - run: docker build --cache-from=$IMAGE_NAME:builder --target builder -t $IMAGE_NAME:builder . |
37 | | - |
38 | | - - name: Build docker image for distribution |
39 | | - run: docker build --cache-from=$IMAGE_NAME:builder --cache-from=$IMAGE_NAME:latest -t $IMAGE_NAME:dev --build-arg NEXT_PUBLIC_GIT_HASH=$GITHUB_SHA . |
40 | | - |
41 | | - - name: Tag docker image as 'latest' |
42 | | - if: ${{ github.ref == 'refs/heads/main' }} |
43 | | - run: docker tag $IMAGE_NAME:dev $IMAGE_NAME:latest |
44 | | - |
45 | | - - name: Tag docker image as '<branch_name>-<git_commit_sha>' |
46 | | - run: docker tag $IMAGE_NAME:dev $IMAGE_NAME:$COMMIT_ID |
47 | | - |
48 | | - - name: Login to Docker Hub |
49 | | - uses: docker/login-action@v3 |
50 | | - with: |
51 | | - username: ${{ secrets.JORE4_DOCKERHUB_USER }} |
52 | | - password: ${{ secrets.JORE4_DOCKERHUB_TOKEN }} |
53 | | - |
54 | | - - name: Push image tagged with git commit details to Docker Hub |
55 | | - run: docker push $IMAGE_NAME:$COMMIT_ID |
56 | | - |
57 | | - - name: Push rest of the tags to Docker Hub |
58 | | - if: ${{ github.ref == 'refs/heads/main' }} |
59 | | - run: | |
60 | | - docker push $IMAGE_NAME:builder |
61 | | - docker push $IMAGE_NAME:latest |
62 | | -
|
63 | 19 | publish_docker_image_to_acr: |
64 | 20 | needs: |
65 | 21 | - run_unit_tests |
|
0 commit comments