|
8 | 8 |
|
9 | 9 | name: Continuous integration |
10 | 10 |
|
11 | | -env: |
12 | | - BASE_IMAGE_NAME: livegrep/base |
13 | | - INDEXER_IMAGE_NAME: livegrep/indexer |
14 | | - NGINX_IMAGE_NAME: livegrep/nginx |
15 | | - |
16 | 11 | jobs: |
17 | 12 | ci: |
18 | 13 | runs-on: ubuntu-24.04 |
|
29 | 24 | bazel-disk-${{ runner.os }}-${{ hashFiles('MODULE.bazel', 'MODULE.bazel.lock') }}- |
30 | 25 | bazel-disk-${{ runner.os }}- |
31 | 26 | - name: bazel build |
32 | | - id: build |
33 | | - run: | |
34 | | - bazel build //... |
35 | | - echo "build_output_file_name=$(./package.sh)" >> $GITHUB_ENV |
| 27 | + run: bazel build //... |
36 | 28 | - name: bazel test |
37 | 29 | run: bazel test --test_arg=-test.v //... |
38 | | - # Run after building so we can use BuildBuddys fetch cache rather than |
39 | | - # first calling bazel fetch ourselves. If a Go file ins't formatted |
40 | | - # corectly it will only take an additional minute or so for CI to fail. |
41 | 30 | - name: gofmt |
42 | 31 | run: | |
43 | 32 | format_errors=$(bazel run @rules_go//go -- fmt ./...) |
|
46 | 35 | echo "$format_errors" |
47 | 36 | exit 1 |
48 | 37 | fi |
49 | | - - name: upload build output |
50 | | - if: ${{ github.event_name == 'push' }} |
51 | | - uses: actions/upload-artifact@v4 |
52 | | - with: |
53 | | - name: "${{ env.build_output_file_name }}" |
54 | | - path: "builds/${{ env.build_output_file_name }}.tgz" |
55 | | - retention-days: 1 |
56 | | - - name: Build images |
57 | | - if: ${{ github.event_name == 'push' }} |
58 | | - run: | |
59 | | - docker build -t $BASE_IMAGE_NAME --file docker/base/Dockerfile --build-arg "livegrep_version=$build_output_file_name" . |
60 | | - docker build -t $INDEXER_IMAGE_NAME . --file docker/indexer/Dockerfile |
61 | | - docker build -t $NGINX_IMAGE_NAME . --file docker/nginx/Dockerfile |
62 | | - - name: Push images |
63 | | - if: ${{ github.event_name == 'push' }} |
64 | | - run: | |
65 | | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin |
66 | | -
|
67 | | - BASE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BASE_IMAGE_NAME |
68 | | - INDEXER_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$INDEXER_IMAGE_NAME |
69 | | - NGINX_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$NGINX_IMAGE_NAME |
70 | | -
|
71 | | - # tag each image with GHCRID:VERSION |
72 | | - VERSION=$(git rev-parse HEAD | head -c10) |
73 | | - docker tag $BASE_IMAGE_NAME $BASE_IMAGE_ID:$VERSION |
74 | | - docker tag $INDEXER_IMAGE_NAME $INDEXER_IMAGE_ID:$VERSION |
75 | | - docker tag $NGINX_IMAGE_NAME $NGINX_IMAGE_ID:$VERSION |
76 | | -
|
77 | | - # this workflow is running on "main" atm so always tag latest |
78 | | - docker tag $BASE_IMAGE_NAME $BASE_IMAGE_ID:latest |
79 | | - docker tag $INDEXER_IMAGE_NAME $INDEXER_IMAGE_ID:latest |
80 | | - docker tag $NGINX_IMAGE_NAME $NGINX_IMAGE_ID:latest |
81 | | -
|
82 | | - docker push $NGINX_IMAGE_ID:$VERSION |
83 | | - docker push $BASE_IMAGE_ID:$VERSION |
84 | | - docker push $INDEXER_IMAGE_ID:$VERSION |
85 | | -
|
86 | | - # it seems like docker doesn't push all tags for an image, you need to |
87 | | - # push each tag as if it were a seperate image -__- |
88 | | - echo "Pushing latest images to test" |
89 | | - docker push $NGINX_IMAGE_ID:latest |
90 | | - docker push $BASE_IMAGE_ID:latest |
91 | | - docker push $INDEXER_IMAGE_ID:latest |
0 commit comments