fix(source filter): dark mode support (#5505) #1323
Workflow file for this run
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: Build and Push Backend Image on Tag | |
on: | |
push: | |
tags: | |
- "*" | |
env: | |
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }} | |
DEPLOYMENT: ${{ contains(github.ref_name, 'cloud') && 'cloud' || 'standalone' }} | |
# don't tag cloud images with "latest" | |
LATEST_TAG: ${{ contains(github.ref_name, 'latest') && !contains(github.ref_name, 'cloud') }} | |
jobs: | |
build-and-push: | |
# TODO: investigate a matrix build like the web container | |
# See https://runs-on.com/runners/linux/ | |
runs-on: | |
- runs-on | |
- runner=${{ matrix.platform == 'linux/amd64' && '8cpu-linux-x64' || '8cpu-linux-arm64' }} | |
- run-id=${{ github.run_id }} | |
- tag=platform-${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ env.LATEST_TAG == 'true' && 'latest' || '' }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Install build-essential | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential | |
- name: Backend Image Docker Build and Push | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: true | |
build-args: | | |
ONYX_VERSION=${{ github.ref_name }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=s3,prefix=cache/${{ github.repository }}/${{ env.DEPLOYMENT }}/backend-${{ env.PLATFORM_PAIR }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} | |
cache-to: type=s3,prefix=cache/${{ github.repository }}/${{ env.DEPLOYMENT }}/backend-${{ env.PLATFORM_PAIR }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: backend-digests-${{ env.PLATFORM_PAIR }}-${{ github.run_id }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push | |
steps: | |
# Needed for trivyignore | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: backend-digests-*-${{ github.run_id }} | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ env.LATEST_TAG == 'true' && 'latest' || '' }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
# trivy has their own rate limiting issues causing this action to flake | |
# we worked around it by hardcoding to different db repos in env | |
# can re-enable when they figure it out | |
# https://github.com/aquasecurity/trivy/discussions/7538 | |
# https://github.com/aquasecurity/trivy-action/issues/389 | |
# Security: Using pinned digest (0.65.0@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436) | |
# Security: No Docker socket mount needed for remote registry scanning | |
- name: Run Trivy vulnerability scanner | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 30 | |
max_attempts: 3 | |
retry_wait_seconds: 10 | |
command: | | |
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy \ | |
-v ${{ github.workspace }}/backend/.trivyignore:/tmp/.trivyignore:ro \ | |
-e TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2" \ | |
-e TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1" \ | |
-e TRIVY_USERNAME="${{ secrets.DOCKER_USERNAME }}" \ | |
-e TRIVY_PASSWORD="${{ secrets.DOCKER_TOKEN }}" \ | |
aquasec/trivy@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436 \ | |
image \ | |
--skip-version-check \ | |
--timeout 20m \ | |
--severity CRITICAL,HIGH \ | |
--ignorefile /tmp/.trivyignore \ | |
docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} |