Skip to content

[Go] squash optimizations #92

[Go] squash optimizations

[Go] squash optimizations #92

name: Dispatch Trigger
on:
push:
branches:
- main
paths:
- "frontend/**"
- "backend/**"
- "backend-spring/**"
workflow_dispatch:
jobs:
triggerDispatch:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install jq
run: sudo apt-get install -y jq
- name: Get changed files
shell: bash
run: |
if git rev-parse HEAD~1 >/dev/null 2>&1; then
if git diff --name-only HEAD~1 HEAD | grep -q 'frontend/'; then
echo "frontend_changed=true" >> $GITHUB_ENV
else
echo "frontend_changed=false" >> $GITHUB_ENV
fi
if git diff --name-only HEAD~1 HEAD | grep -q 'backend/'; then
echo "backend_changed=true" >> $GITHUB_ENV
else
echo "backend_changed=false" >> $GITHUB_ENV
fi
if git diff --name-only HEAD~1 HEAD | grep -q 'backend-spring/'; then
echo "spring_changed=true" >> $GITHUB_ENV
else
echo "spring_changed=false" >> $GITHUB_ENV
fi
else
echo "Checking all files since there's no previous commit."
if git ls-tree --name-only -r HEAD | grep -q 'frontend/'; then
echo "frontend_changed=true" >> $GITHUB_ENV
else
echo "frontend_changed=false" >> $GITHUB_ENV
fi
if git ls-tree --name-only -r HEAD | grep -q 'backend/'; then
echo "backend_changed=true" >> $GITHUB_ENV
else
echo "backend_changed=false" >> $GITHUB_ENV
fi
if git ls-tree --name-only -r HEAD | grep -q 'backend-spring/'; then
echo "spring_changed=true" >> $GITHUB_ENV
else
echo "spring_changed=false" >> $GITHUB_ENV
fi
fi
- name: Prepare payload
id: prepare_payload
run: |
COMMIT_MESSAGE=$(echo "${{ github.event.head_commit.message }}" | jq -R -s '. | rtrimstr("\n")')
echo "payload={\"ref\": \"${{ github.ref }}\", \"sha\": \"${{ github.sha }}\", \"commit_message\": $COMMIT_MESSAGE}" >> $GITHUB_ENV
- name: Trigger Repository Dispatch for Frontend Changes
if: env.frontend_changed == 'true'
uses: peter-evans/repository-dispatch@v3
with:
event-type: frontend-changes
client-payload: ${{ env.payload }}
- name: Trigger Repository Dispatch for Backend Changes
if: env.backend_changed == 'true'
uses: peter-evans/repository-dispatch@v3
with:
event-type: backend-changes
client-payload: ${{ env.payload }}
- name: Trigger Repository Dispatch for Backend Spring Changes
if: env.spring_changed == 'true'
uses: peter-evans/repository-dispatch@v3
with:
event-type: spring-changes
client-payload: ${{ env.payload }}