Skip to content

feat(CI): Improve Github actions tests #1929

feat(CI): Improve Github actions tests

feat(CI): Improve Github actions tests #1929

Workflow file for this run

name: Test
on:
push:
branches:
- '**'
paths-ignore:
- '.github/workflows/**'
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect_changes:
runs-on: ubuntu-latest
outputs:
changed_project: ${{ steps.detect_changes.outputs.changed_project }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Fetch current and previous commit
- name: Detect changed project
id: detect_changes
run: |
PROJECT_DIRECTORIES=$(find * -type f -name build.yml -not -path "terra*" | xargs dirname | sort | uniq)
COMMIT_BEFORE=$(git rev-parse HEAD~1)
COMMIT_AFTER=${{ github.sha }}
CHANGED_PROJECT=""
for dir in $PROJECT_DIRECTORIES; do
if git diff --name-only $COMMIT_BEFORE $COMMIT_AFTER | grep -q "^$dir/"; then
CHANGED_PROJECT="$dir"
break
fi
done
echo "Changed project: $CHANGED_PROJECT"
echo "changed_project=$CHANGED_PROJECT" >> $GITHUB_ENV
echo "::set-output name=changed_project::$CHANGED_PROJECT"
build:
needs: detect_changes
runs-on: ubuntu-latest
if: needs.detect_changes.outputs.changed_project != ''
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
with:
install: true
- name: Debug before build
run: |
echo "Building project: ${{ needs.detect_changes.outputs.changed_project }}"
- name: Build
run: |
touch .env # Create dummy env file
cd ${{ needs.detect_changes.outputs.changed_project }}
docker buildx bake -f build.yml --set node_1.tags=node