Skip to content

Commit

Permalink
chore(gha): fixed tests execution for main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmorano committed Jul 30, 2024
1 parent 16b3a3d commit c4b4e71
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,31 @@ jobs:
- name: Check if there were changes for the service
id: metadata
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]] \
|| [[ "${{ github.event_name }}" == "push" ]]
then
if git log --pretty=format:'%h' -n 1 backend-services/${{ matrix.service }} | grep -q ${{ github.sha }}
then
echo "SERVICE_CHANGED=false" | tee -a "$GITHUB_OUTPUT"
case "${GITHUB_EVENT_NAME}" in
pull_request)
if git log --pretty=format:'%h' -n 1 backend-services/${{ matrix.service }} | grep -q ${{ github.sha }}
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
;;
push) # main branch should always trigger the job
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [ "${BRANCH_NAME}" == "main" ]
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
else
if git log --pretty=format:'%h' -n 1 backend-services/${{ matrix.service }} | grep -q ${{ github.sha }}
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
fi
;;
*) # ie workflow_dispatch
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
else
echo "SERVICE_CHANGED=false" | tee -a "$GITHUB_OUTPUT"
fi
else # if the event is not a push or pull_request, then we assume that the service has changed
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
;;
esac
- name: Setup JDK 21
if: steps.metadata.outputs.SERVICE_CHANGED == true
Expand Down

0 comments on commit c4b4e71

Please sign in to comment.