Skip to content

Commit

Permalink
Update and rename apple-fix-to-fork.yml to apple-format-code-to-push.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
housemecn authored Dec 24, 2024
1 parent 0c7c902 commit 4d4dbbe
Showing 1 changed file with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Apply Fix to Fork
name: Apply format code to Push

on:
push:
pull_request_target:
types: [synchronize]

jobs:
apply-fix:
apply-format-code:
strategy:
matrix:
go-version: [ 'stable' ]
Expand All @@ -15,13 +13,6 @@ jobs:
steps:
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Print repository information
run: |
echo "Base repository: ${{ github.event.pull_request.base.repo.full_name }}"
echo "Head repository: ${{ github.event.pull_request.head.repo.full_name }}"
- name: Setup Golang ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
Expand All @@ -43,17 +34,12 @@ jobs:
-s "prefix(github.com/gogf/gf/example)" \
./
- name: Check for changes
# Check if the event is a push or a pull request from a forked repository
if: github.event_name == 'push'|| (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork == true)
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "HAS_CHANGES=true" >> $GITHUB_ENV
else
echo "HAS_CHANGES=false" >> $GITHUB_ENV
fi
- name: Output all environment variables
run: |
env
fi
- name: Configure Git
run: |
if [[ "$HAS_CHANGES" == 'true' ]]; then
Expand All @@ -63,8 +49,11 @@ jobs:
echo "HAS_CHANGES= $HAS_CHANGES "
fi
- name: Commit and push changes
if: env.HAS_CHANGES == 'true'
run: |
git add .
git commit -m "Apply gci import order changes [skip ci]"
git push origin ${{ github.event.pull_request.head.ref }}
if [[ "$HAS_CHANGES" == 'true' ]]; then
git add .
git commit -m "Apply gci import order changes [skip ci]"
git push origin ${{ github.event.pull_request.head.ref }}
else
echo "No change to commit push"
fi

0 comments on commit 4d4dbbe

Please sign in to comment.