@@ -19,14 +19,30 @@ jobs:
1919 git config --global user.email "ci-build@aemforms"
2020 git config --global user.name "ci-build"
2121
22+ - name : Validate branch names
23+ id : validate
24+ run : |
25+ echo "Validating branch names..."
26+ if ! [[ "${{ github.event.pull_request.head.ref }}" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
27+ echo "Invalid characters in head ref"
28+ exit 1
29+ fi
30+ if ! [[ "${{ github.event.pull_request.base.ref }}" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
31+ echo "Invalid characters in base ref"
32+ exit 1
33+ fi
34+ echo "::set-output name=head_ref::${{ github.event.pull_request.head.ref }}"
35+ echo "::set-output name=base_ref::${{ github.event.pull_request.base.ref }}"
36+
2237 - name : Sync with Base Branch
2338 run : |
24- git fetch origin
25- git checkout ${{ github.event.pull_request.base.ref }}
26- git pull origin ${{ github.event.pull_request.base.ref }}
27- git checkout ${{ github.event.pull_request.head.ref }}
28- git pull origin ${{ github.event.pull_request.head.ref }}
29- git rebase ${{ github.event.pull_request.base.ref }}
30- git push --force origin ${{ github.event.pull_request.head.ref }}
39+ git fetch origin ${{ steps.validate.outputs.head_ref }}
40+ git fetch origin ${{ steps.validate.outputs.base_ref }}
41+ git checkout ${{ steps.validate.outputs.base_ref }}
42+ git pull origin ${{ steps.validate.outputs.base_ref }}
43+ git checkout ${{ steps.validate.outputs.head_ref }}
44+ git pull origin ${{ steps.validate.outputs.head_ref }}
45+ git rebase ${{ steps.validate.outputs.base_ref }}
46+ git push --force origin ${{ steps.validate.outputs.head_ref }}
3147 env :
3248 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments