From dbba7c31ac354146ddfa5dc901e1e5586b542fc5 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sun, 31 Mar 2024 17:24:18 -0700 Subject: update CI and test --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2bb67a9..26989559 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,18 +18,38 @@ jobs: prepare: runs-on: ubuntu-latest outputs: - web_changed: ${{ steps.set_outputs.outputs.web_changed }} - extension_changed: ${{ steps.set_outputs.outputs.extension_changed }} - cf_ai_backend_changed: ${{ steps.set_outputs.outputs.cf_ai_backend_changed }} + web_changed: ${{ steps.detect_changes.outputs.web_changed }} + extension_changed: ${{ steps.detect_changes.outputs.extension_changed }} + cf_ai_backend_changed: ${{ steps.detect_changes.outputs.cf_ai_backend_changed }} steps: - uses: actions/checkout@v3 - - name: Set Outputs - id: set_outputs + - name: Fetching all history for all tags and branches + run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + - name: Detect Changes + id: detect_changes run: | - echo "web_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/web/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT - echo "extension_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/extension/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT - echo "cf_ai_backend_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/cf-ai-backend/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT - + WEB_CHANGED="false" + EXTENSION_CHANGED="false" + CF_AI_BACKEND_CHANGED="false" + if [ "${{ github.event_name }}" = "push" ]; then + DIFF_REF="${{ github.event.before }} ${{ github.sha }}" + else + DIFF_REF="${{ github.base_ref }}...${{ github.head_ref }}" + fi + if git diff --name-only $DIFF_REF | grep -q 'apps/web/'; then + WEB_CHANGED="true" + fi + if git diff --name-only $DIFF_REF | grep -q 'apps/extension/'; then + EXTENSION_CHANGED="true" + fi + if git diff --name-only $DIFF_REF | grep -q 'apps/cf-ai-backend/'; then + CF_AI_BACKEND_CHANGED="true" + fi + echo "web_changed=$WEB_CHANGED" >> $GITHUB_OUTPUT + echo "extension_changed=$EXTENSION_CHANGED" >> $GITHUB_OUTPUT + echo "cf_ai_backend_changed=$CF_AI_BACKEND_CHANGED" >> $GITHUB_OUTPUT + echo "Differences detected: WEB=$WEB_CHANGED, EXTENSION=$EXTENSION_CHANGED, CF_AI_BACKEND=$CF_AI_BACKEND_CHANGED" + build-extension: needs: prepare if: needs.prepare.outputs.extension_changed == 'true' -- cgit v1.2.3