ci: consolidate preflight check (#6)

This commit is contained in:
Marc 2023-08-11 01:41:52 -04:00 committed by GitHub
parent 699007bae9
commit 2003c1df35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,18 +14,25 @@ jobs:
runs-on: ubuntu-latest
name: Preflight checks
outputs:
be_changed: ${{ steps.be-changes.outputs.be_changed }}
fe_changed: ${{ steps.fe-changes.outputs.fe_changed }}
be_changed: ${{ steps.change-check.outputs.be_changed }}
fe_changed: ${{ steps.change-check.outputs.fe_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Change check (frontend)
id: fe-changes
- name: Change check
id: change-check
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ] | [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./.github)" ]
if [ "${{ github.ref }}" == "refs/heads/main" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
echo "be_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./.github)" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
echo "be_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./frontend
@ -33,15 +40,6 @@ jobs:
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Change check (backend)
id: be-changes
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ] | [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./.github)" ]
then
echo "be_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./backend
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./backend)" ]
then
echo "be_changed=true" >> "$GITHUB_OUTPUT"