Merge pull request #157 from carverauto/update/cant-query-past-hour #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Threadr Control Plane Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/workflows/threadr-control-plane-image.yml" | |
| - ".bazelrc" | |
| - ".bazelversion" | |
| - "MODULE.bazel" | |
| - "BUILD.bazel" | |
| - "build/**" | |
| - "docker/images/**" | |
| - "tools/buildbuddy/**" | |
| - "buildbuddy_setup_docker_auth.sh" | |
| - "elixir/threadr/**" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-and-push: | |
| runs-on: arc-runner-set | |
| environment: main | |
| timeout-minutes: 45 | |
| env: | |
| LANG: C.UTF-8 | |
| LC_ALL: C.UTF-8 | |
| ELIXIR_ERL_OPTIONS: +fnu | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: elixir/threadr/assets/package-lock.json | |
| - name: Install frontend dependencies | |
| run: | | |
| cd elixir/threadr/assets | |
| npm ci --no-audit --no-fund | |
| - name: Set up Bazelisk | |
| uses: bazelbuild/setup-bazelisk@v3 | |
| - name: Configure Bazel execution mode | |
| env: | |
| BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} | |
| run: | | |
| if [ -z "${BUILDBUDDY_API_KEY}" ]; then | |
| echo "BUILDBUDDY_API_KEY must be configured for Threadr Bazel CI" >&2 | |
| exit 1 | |
| fi | |
| chmod +x tools/buildbuddy/write_remote_rc.sh | |
| tools/buildbuddy/write_remote_rc.sh | |
| echo "BAZEL_BUILD_CONFIG=remote" >> "${GITHUB_ENV}" | |
| echo "Using BuildBuddy remote execution" | |
| - name: Configure Docker auth | |
| env: | |
| GHCR_USERNAME: ${{ github.actor }} | |
| GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| chmod +x buildbuddy_setup_docker_auth.sh | |
| ./buildbuddy_setup_docker_auth.sh | |
| - name: Build all Bazel targets | |
| run: | | |
| bazel build -c opt \ | |
| //elixir/threadr:release_tar \ | |
| //docker/images:control_plane_image_amd64 \ | |
| --config="${BAZEL_BUILD_CONFIG}" | |
| - name: Run Bazel tests | |
| run: | | |
| TEST_TARGETS="$(bazel query 'tests(//...)' | tr '\n' ' ')" | |
| if [ -z "${TEST_TARGETS}" ]; then | |
| echo "No Bazel test targets defined; skipping bazel test" | |
| exit 0 | |
| fi | |
| bazel test -c opt --config="${BAZEL_BUILD_CONFIG}" ${TEST_TARGETS} | |
| - name: Build and push image via Bazel | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| bazel run -c opt //docker/images:push_all --config="${BAZEL_BUILD_CONFIG}" | |
| - name: Update production digest pin | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| chmod +x elixir/threadr/tools/bazel/update_production_digest.sh | |
| elixir/threadr/tools/bazel/update_production_digest.sh \ | |
| --image ghcr.io/carverauto/threadr/threadr-control-plane \ | |
| --tag main \ | |
| --file k8s/threadr/overlays/control-plane/production/image-patch.yaml | |
| elixir/threadr/tools/bazel/update_production_digest.sh \ | |
| --image ghcr.io/carverauto/threadr/threadr-control-plane \ | |
| --tag main \ | |
| --file k8s/threadr/overlays/worker/production/image-patch.yaml | |
| elixir/threadr/tools/bazel/update_production_digest.sh \ | |
| --image ghcr.io/carverauto/threadr/threadr-control-plane \ | |
| --tag main \ | |
| --file k8s/threadr/overlays/control-plane/production/control-plane-config-patch.yaml | |
| - name: Commit production digest pin | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| if git diff --quiet -- \ | |
| k8s/threadr/overlays/control-plane/production/image-patch.yaml \ | |
| k8s/threadr/overlays/worker/production/image-patch.yaml \ | |
| k8s/threadr/overlays/control-plane/production/control-plane-config-patch.yaml; then | |
| echo "production digest pin already current" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add \ | |
| k8s/threadr/overlays/control-plane/production/image-patch.yaml \ | |
| k8s/threadr/overlays/worker/production/image-patch.yaml \ | |
| k8s/threadr/overlays/control-plane/production/control-plane-config-patch.yaml | |
| git commit -m "ci: update production image digest pins" | |
| git push |