mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-09 14:11:33 +02:00
Dev Experience (#2912)
This commit is contained in:
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@ -26,4 +26,4 @@ N/A
|
|||||||
|
|
||||||
## Backporting (check the box to trigger backport action)
|
## Backporting (check the box to trigger backport action)
|
||||||
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.
|
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.
|
||||||
[ ] This PR should be backported (make sure to check that the backport attempt succeeds)
|
- [ ] This PR should be backported (make sure to check that the backport attempt succeeds)
|
||||||
|
77
.github/workflows/pr-backport-autotrigger.yml
vendored
77
.github/workflows/pr-backport-autotrigger.yml
vendored
@ -10,43 +10,84 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check for Backport Checkbox
|
- name: Set up Git
|
||||||
id: checkbox-check
|
|
||||||
run: |
|
run: |
|
||||||
PR_BODY="${{ github.event.pull_request.body }}"
|
git config user.name "github-actions[bot]"
|
||||||
if [[ "$PR_BODY" == *"[x] This PR should be backported"* ]]; then
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
echo "::set-output name=backport::true"
|
|
||||||
|
- name: Check for Backport Label
|
||||||
|
id: check-label
|
||||||
|
run: |
|
||||||
|
labels="${{ github.event.pull_request.labels.*.name }}"
|
||||||
|
if [[ "$labels" == *"backport"* ]]; then
|
||||||
|
echo "backport=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "::set-output name=backport::false"
|
echo "backport=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: List and sort release branches
|
- name: List and sort release branches
|
||||||
id: list-branches
|
id: list-branches
|
||||||
run: |
|
run: |
|
||||||
git fetch --all
|
BRANCHES=$(git for-each-ref --format='%(refname:short)' refs/remotes/origin/release/* | sed 's|origin/release/||' | sort -Vr)
|
||||||
BRANCHES=$(git branch -r | grep 'origin/release/v' | sed 's|origin/release/v||' | sort -Vr)
|
|
||||||
BETA=$(echo "$BRANCHES" | head -n 1)
|
BETA=$(echo "$BRANCHES" | head -n 1)
|
||||||
STABLE=$(echo "$BRANCHES" | head -n 2 | tail -n 1)
|
STABLE=$(echo "$BRANCHES" | head -n 2 | tail -n 1)
|
||||||
echo "::set-output name=beta::$BETA"
|
echo "beta=$BETA" >> $GITHUB_OUTPUT
|
||||||
echo "::set-output name=stable::$STABLE"
|
echo "stable=$STABLE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Fetch latest tags for beta and stable
|
||||||
|
# Beta tag is in the format vX.Y.Z-beta.W
|
||||||
|
# Stable tag is in the format vX.Y.Z
|
||||||
|
LATEST_BETA_TAG=$(git tag -l "v*.*.0-beta.*" | sort -Vr | head -n 1)
|
||||||
|
LATEST_STABLE_TAG=$(git tag -l "v*.*.*" | grep -v -- "-beta" | sort -Vr | head -n 1)
|
||||||
|
|
||||||
|
# Increment latest beta tag
|
||||||
|
NEW_BETA_TAG=$(echo $LATEST_BETA_TAG | awk -F '.' '{print $1 "." $2 ".0-beta." ($4+1)}')
|
||||||
|
# Increment latest stable tag
|
||||||
|
NEW_STABLE_TAG=$(echo $LATEST_STABLE_TAG | awk -F '.' '{print $1 "." $2 "." ($3+1)}')
|
||||||
|
echo "latest_beta_tag=$LATEST_BETA_TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "latest_stable_tag=$LATEST_STABLE_TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "new_beta_tag=$NEW_BETA_TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "new_stable_tag=$NEW_STABLE_TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Echo branch and tag information
|
||||||
|
run: |
|
||||||
|
echo "Beta branch: ${{ steps.list-branches.outputs.beta }}"
|
||||||
|
echo "Stable branch: ${{ steps.list-branches.outputs.stable }}"
|
||||||
|
echo "Latest beta tag: ${{ steps.list-branches.outputs.latest_beta_tag }}"
|
||||||
|
echo "Latest stable tag: ${{ steps.list-branches.outputs.latest_stable_tag }}"
|
||||||
|
echo "New beta tag: ${{ steps.list-branches.outputs.new_beta_tag }}"
|
||||||
|
echo "New stable tag: ${{ steps.list-branches.outputs.new_stable_tag }}"
|
||||||
|
|
||||||
- name: Trigger Backport
|
- name: Trigger Backport
|
||||||
if: steps.checkbox-check.outputs.backport == 'true'
|
if: steps.check-label.outputs.backport == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
set -e
|
||||||
echo "Backporting to beta ${{ steps.list-branches.outputs.beta }} and stable ${{ steps.list-branches.outputs.stable }}"
|
echo "Backporting to beta ${{ steps.list-branches.outputs.beta }} and stable ${{ steps.list-branches.outputs.stable }}"
|
||||||
# Fetch all history for all branches and tags
|
|
||||||
git fetch --prune --unshallow
|
|
||||||
# Checkout the beta branch
|
# Checkout the beta branch
|
||||||
git checkout ${{ steps.list-branches.outputs.beta }}
|
git checkout ${{ steps.list-branches.outputs.beta }}
|
||||||
# Cherry-pick the last commit from the merged PR
|
# Cherry-pick the last commit from the merged PR
|
||||||
git cherry-pick ${{ github.event.pull_request.merge_commit_sha }}
|
git cherry-pick -m 1 ${{ github.event.pull_request.merge_commit_sha }} || {
|
||||||
# Push the changes to the beta branch
|
echo "Cherry-pick to beta failed due to conflicts."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
# Create new beta tag
|
||||||
|
git tag ${{ steps.list-branches.outputs.new_beta_tag }}
|
||||||
|
# Push the changes and tag to the beta branch
|
||||||
git push origin ${{ steps.list-branches.outputs.beta }}
|
git push origin ${{ steps.list-branches.outputs.beta }}
|
||||||
|
git push origin ${{ steps.list-branches.outputs.new_beta_tag }}
|
||||||
# Checkout the stable branch
|
# Checkout the stable branch
|
||||||
git checkout ${{ steps.list-branches.outputs.stable }}
|
git checkout ${{ steps.list-branches.outputs.stable }}
|
||||||
# Cherry-pick the last commit from the merged PR
|
# Cherry-pick the last commit from the merged PR
|
||||||
git cherry-pick ${{ github.event.pull_request.merge_commit_sha }}
|
git cherry-pick -m 1 ${{ github.event.pull_request.merge_commit_sha }} || {
|
||||||
# Push the changes to the stable branch
|
echo "Cherry-pick to stable failed due to conflicts."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
# Create new stable tag
|
||||||
|
git tag ${{ steps.list-branches.outputs.new_stable_tag }}
|
||||||
|
# Push the changes and tag to the stable branch
|
||||||
git push origin ${{ steps.list-branches.outputs.stable }}
|
git push origin ${{ steps.list-branches.outputs.stable }}
|
||||||
|
git push origin ${{ steps.list-branches.outputs.new_stable_tag }}
|
||||||
|
Reference in New Issue
Block a user