Skip to content

reuse recent and same goal output #808

reuse recent and same goal output

reuse recent and same goal output #808

Workflow file for this run

name: Build and Publish
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: "The tag to build the image with. Format *.*.*((beta|rc)*)?"
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docker-metadata:
name: Generate docker metadata
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'require-build')) || (github.event_name != 'pull_request' && !cancelled()) }}
outputs:
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
annotations: ${{steps.meta.outputs.annotations}}
platforms: |
linux/amd64
${{(startsWith(github.ref, 'refs/tags/') && 'linux/arm64') || ''}}
should-build-frontend: ${{steps.decide.outputs.should-build-frontend}}
should-build-backend: ${{steps.decide.outputs.should-build-backend}}
e2e-frontend: ${{steps.decide.outputs.e2e-frontend}}
e2e-backend: ${{steps.decide.outputs.e2e-backend}}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
cache-dependency-path: .github/actions/*/package-lock.json
- run: npm ci
working-directory: .github/actions/decide
- name: Decide
id: decide
uses: ./.github/actions/decide/
with:
pr-e2e-frontend-label-prefix: 'e2e-frontend:'
pr-e2e-backend-label-prefix: 'e2e-backend:'
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ github.token }}
images: "{0}/{1}"
tags: |
type=raw,value=branch-{{branch}},enable=${{ !startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/pull/') }}
type=sha,prefix=sha-,format=long,suffix=-dev,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
type=sha,prefix=sha-,format=long,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=pr
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{version}}
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}}.{{minor}}
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}}
build-backend:
name: Build and Push Backend Image
runs-on: ubuntu-latest
needs: docker-metadata
if: ${{needs.docker-metadata.outputs.should-build-backend == 'true'}}
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push backend
uses: docker/build-push-action@v6
with:
context: backend
platforms: ${{needs.docker-metadata.outputs.platforms}}
push: true
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'backend')}}
labels: ${{needs.docker-metadata.outputs.labels}}
annotations: ${{needs.docker-metadata.outputs.annotations}}
cache-from: type=gha
cache-to: type=gha,mode=max
build-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest
needs: docker-metadata
if: ${{needs.docker-metadata.outputs.should-build-frontend == 'true'}}
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push frontend
uses: docker/build-push-action@v6
with:
context: .
file: ./frontend/Dockerfile
platforms: ${{needs.docker-metadata.outputs.platforms}}
push: true
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'frontend')}}
labels: ${{needs.docker-metadata.outputs.labels}}
annotations: ${{needs.docker-metadata.outputs.annotations}}
cache-from: type=gha
cache-to: type=gha,mode=max
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: e2e
needs:
- docker-metadata
- build-backend
- build-frontend
if: |
!cancelled() &&
needs.docker-metadata.outputs.e2e-backend &&
needs.docker-metadata.outputs.e2e-frontend &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
cache-dependency-path: e2e/package-lock.json
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Fetch Images
run: ./prepare-test.sh
env:
E2E_DOCKER_TAG_FRONTEND: ${{needs.docker-metadata.outputs.e2e-frontend}}
E2E_DOCKER_TAG_BACKEND: ${{needs.docker-metadata.outputs.e2e-backend}}
- name: Run tests
run: ./start-test.sh
env:
E2E_DOCKER_TAG_FRONTEND: ${{needs.docker-metadata.outputs.e2e-frontend}}
E2E_DOCKER_TAG_BACKEND: ${{needs.docker-metadata.outputs.e2e-backend}}
E2E_LLM_PROVIDER: ${{vars.E2E_LLM_PROVIDER}}
E2E_LLM_MODEL: ${{vars.E2E_LLM_MODEL || ''}}
E2E_LLM_CREDENTIALS: ${{secrets.E2E_LLM_CREDENTIALS}}
E2E_EMBEDDING_PROVIDER: ${{vars.E2E_EMBEDDING_PROVIDER || 'openai'}}
E2E_EMBEDDING_MODEL: ${{vars.E2E_EMBEDDING_MODEL || ''}}
E2E_EMBEDDING_CREDENTIALS: ${{secrets.E2E_EMBEDDING_CREDENTIALS}}
E2E_RERANKER_PROVIDER: ${{vars.E2E_RERANKER_PROVIDER || 'jinaai'}}
E2E_RERANKER_MODEL: ${{vars.E2E_RERANKER_MODEL || ''}}
E2E_RERANKER_CREDENTIALS: ${{secrets.E2E_RERANKER_CREDENTIALS}}
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: e2e-report
path: e2e/playwright-report/
retention-days: 30
e2e-test-deploy:
name: "Deploy E2E Test Results"
runs-on: ubuntu-latest
needs: e2e-test
if: "!(contains(needs.*.result, 'skipped')) && !cancelled()"
defaults:
run:
working-directory: e2e
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/download-artifact@v4
with:
name: e2e-report
path: e2e/playwright-report/
- name: Deploy Test Results to Vercel
id: deploy-test-result
run: |
deploy_message=$(./deploy-test-result.sh)
echo "deploy-message=${deploy_message}" >> $GITHUB_OUTPUT
if: "!cancelled()"
env:
VERCEL_TOKEN: ${{secrets.E2E_VERCEL_TOKEN}}
VERCEL_ORG_ID: ${{secrets.E2E_VERCEL_ORG_ID}}
VERCEL_PROJECT_ID: ${{secrets.E2E_VERCEL_PROJECT_ID}}
VERCEL_CLI_ARGS: ${{(github.ref == 'refs/heads/main' && '--prod') || ''}}
- name: Find PR Comment
uses: peter-evans/find-comment@v3
if: github.event.pull_request.number
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: E2E Result Deployment
- name: Upsert Comment on PR
uses: peter-evans/create-or-update-comment@v4
if: github.event.pull_request.number
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### E2E Result Deployment
${{steps.deploy-test-result.outputs.deploy-message}}
edit-mode: replace