Created
June 11, 2025 09:38
-
-
Save wottpal/f7310b6ab2a620f1b0d033e04e6f8a43 to your computer and use it in GitHub Desktop.
Revisions
-
wottpal created this gist
Jun 11, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Merge Branch on: workflow_dispatch: jobs: merge: name: Merge Branch runs-on: ubuntu-latest env: MAIN_BRANCH: develop FEATURE_BRANCH: feature steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_TOKEN }} - name: Configure Git with Bot User run: | USER_DATA=$(curl -s -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github+json" https://api.github.com/user) # Extract name and login, fall back to login if name is not set USER_NAME=$(echo "$USER_DATA" | jq -r '.name // .login') USER_LOGIN=$(echo "$USER_DATA" | jq -r '.login') git config user.name "$USER_NAME" git config user.email "[email protected]" echo "Git configured with user '$USER_NAME' ([email protected])" - name: Merge feature branch into main branch run: | set -e echo "Fetching latest state from remote..." git fetch origin echo "Checking out $MAIN_BRANCH..." git checkout $MAIN_BRANCH echo "Resetting local $MAIN_BRANCH to remote state..." git reset --hard origin/$MAIN_BRANCH echo "Merging remote '$FEATURE_BRANCH' into '$MAIN_BRANCH'..." git merge "origin/$FEATURE_BRANCH" --no-ff -m "Merge branch '$FEATURE_BRANCH'" - name: Push changes to remote run: | set -e echo "Pushing changes to $MAIN_BRANCH..." git push origin $MAIN_BRANCH