Merge pull request #23037 from manadart/4.0-remove-lxd-profiles #422
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 characters
| name: Merge | |
| on: | |
| push: | |
| branches: ["2.9", "3.6", "4.0"] | |
| jobs: | |
| check-merge: | |
| name: Check for conflicts | |
| runs-on: ubuntu-latest | |
| env: | |
| MERGE_TARGETS: | | |
| 2.9: 3.1 | |
| 3.6: 4.0 | |
| 4.0: main | |
| steps: | |
| - name: Determine source/target branches | |
| id: branch | |
| run: | | |
| set -x | |
| SOURCE_BRANCH=${{ github.ref_name }} | |
| echo "source=$SOURCE_BRANCH" >> "$GITHUB_OUTPUT" | |
| TARGET_BRANCH=$(echo "$MERGE_TARGETS" | yq ".\"$SOURCE_BRANCH\"") | |
| echo "target=$TARGET_BRANCH" >> "$GITHUB_OUTPUT" | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ steps.branch.outputs.source }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: false | |
| # We need to do this before trying to merge, because if the merge | |
| # creates conflicts in go.mod, we won't be able to use the go command. | |
| - name: Pre-compile try-merge script | |
| run: | | |
| go install ./scripts/try-merge | |
| - name: Attempt to merge | |
| id: merge | |
| env: | |
| SOURCE_BRANCH: ${{ steps.branch.outputs.source }} | |
| TARGET_BRANCH: ${{ steps.branch.outputs.target }} | |
| run: | | |
| set -x | |
| git fetch origin "$TARGET_BRANCH" | |
| git branch "$TARGET_BRANCH" "origin/$TARGET_BRANCH" | |
| # Need to set Git username/email to do the merge (yawn) | |
| git config user.name 'jujubot' | |
| git config user.email 'fake@address.me' | |
| set +e | |
| git switch "$TARGET_BRANCH" | |
| git merge "$SOURCE_BRANCH" | |
| case $? in | |
| 0) | |
| echo "conflicts=false" >> "$GITHUB_OUTPUT" | |
| ;; | |
| 1) | |
| echo "conflicts=true" >> "$GITHUB_OUTPUT" | |
| ;; | |
| *) | |
| exit $? | |
| ;; | |
| esac | |
| - name: Generate notification message | |
| if: steps.merge.outputs.conflicts == 'true' | |
| id: message | |
| env: | |
| SOURCE_BRANCH: ${{ steps.branch.outputs.source }} | |
| TARGET_BRANCH: ${{ steps.branch.outputs.target }} | |
| EMAIL_TO_MM_USER: ${{ secrets.EMAIL_TO_MM_USER }} | |
| IGNORE_EMAILS: ${{ secrets.MERGE_NOTIFY_IGNORE_EMAILS }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| MESSAGE=$(try-merge errmsg) | |
| echo "message=$MESSAGE" >> "$GITHUB_OUTPUT" | |
| - name: Notify if merge has conflicts | |
| if: steps.merge.outputs.conflicts == 'true' && steps.message.outputs.message != '' | |
| uses: ./.github/actions/notify-mm | |
| with: | |
| mm_url: ${{ secrets.MM_URL }} | |
| mm_token: ${{ secrets.MM_TOKEN }} | |
| channel: ${{ secrets.MM_CHANNEL }} | |
| message: ${{ steps.message.outputs.message }} |