Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 1 addition & 55 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:

name: Continuous integration

env:
BASE_IMAGE_NAME: livegrep/base
INDEXER_IMAGE_NAME: livegrep/indexer
NGINX_IMAGE_NAME: livegrep/nginx

jobs:
ci:
runs-on: ubuntu-24.04
Expand All @@ -29,15 +24,9 @@ jobs:
bazel-disk-${{ runner.os }}-${{ hashFiles('MODULE.bazel', 'MODULE.bazel.lock') }}-
bazel-disk-${{ runner.os }}-
- name: bazel build
id: build
run: |
bazel build //...
echo "build_output_file_name=$(./package.sh)" >> $GITHUB_ENV
run: bazel build //...
- name: bazel test
run: bazel test --test_arg=-test.v //...
# Run after building so we can use BuildBuddys fetch cache rather than
# first calling bazel fetch ourselves. If a Go file ins't formatted
# corectly it will only take an additional minute or so for CI to fail.
- name: gofmt
run: |
format_errors=$(bazel run @rules_go//go -- fmt ./...)
Expand All @@ -46,46 +35,3 @@ jobs:
echo "$format_errors"
exit 1
fi
- name: upload build output
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v4
with:
name: "${{ env.build_output_file_name }}"
path: "builds/${{ env.build_output_file_name }}.tgz"
retention-days: 1
- name: Build images
if: ${{ github.event_name == 'push' }}
run: |
docker build -t $BASE_IMAGE_NAME --file docker/base/Dockerfile --build-arg "livegrep_version=$build_output_file_name" .
docker build -t $INDEXER_IMAGE_NAME . --file docker/indexer/Dockerfile
docker build -t $NGINX_IMAGE_NAME . --file docker/nginx/Dockerfile
- name: Push images
if: ${{ github.event_name == 'push' }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

BASE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BASE_IMAGE_NAME
INDEXER_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$INDEXER_IMAGE_NAME
NGINX_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$NGINX_IMAGE_NAME

# tag each image with GHCRID:VERSION
VERSION=$(git rev-parse HEAD | head -c10)
docker tag $BASE_IMAGE_NAME $BASE_IMAGE_ID:$VERSION
docker tag $INDEXER_IMAGE_NAME $INDEXER_IMAGE_ID:$VERSION
docker tag $NGINX_IMAGE_NAME $NGINX_IMAGE_ID:$VERSION

# this workflow is running on "main" atm so always tag latest
docker tag $BASE_IMAGE_NAME $BASE_IMAGE_ID:latest
docker tag $INDEXER_IMAGE_NAME $INDEXER_IMAGE_ID:latest
docker tag $NGINX_IMAGE_NAME $NGINX_IMAGE_ID:latest

docker push $NGINX_IMAGE_ID:$VERSION
docker push $BASE_IMAGE_ID:$VERSION
docker push $INDEXER_IMAGE_ID:$VERSION

# it seems like docker doesn't push all tags for an image, you need to
# push each tag as if it were a seperate image -__-
echo "Pushing latest images to test"
docker push $NGINX_IMAGE_ID:latest
docker push $BASE_IMAGE_ID:latest
docker push $INDEXER_IMAGE_ID:latest