Release/2.1.2 #92
Workflow file for this run
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: Sync main to develop after release | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| sync_main_to_develop: | |
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| node-version: [20.x] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure Git identity | |
| run: | | |
| git config user.name ${{ github.actor }} | |
| git config user.email ${{ github.actor }}@users.noreply.github.com | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| cache-dependency-path: './common/config/rush/pnpm-lock.yaml' | |
| - name: Install Python distutils (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| python3 -m pip install setuptools --break-system-packages | |
| - name: Install Python distutils (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-distutils | |
| python3 -m pip install setuptools --break-system-packages | |
| - name: Install native deps for node-canvas (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew update | |
| brew install pkg-config cairo pango libpng jpeg giflib librsvg | |
| - name: Install native deps for node-canvas (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev pkg-config | |
| - name: Install latest pnpm | |
| run: npm install -g pnpm@10.7.0 | |
| - name: Install rush | |
| run: node common/scripts/install-run-rush.js install --bypass-policy | |
| - name: Read vchart version from package.json | |
| id: package_version | |
| uses: xile611/read-package-version-action@main | |
| with: | |
| path: packages/vchart | |
| - name: Compute sync branch name and check existence | |
| id: sync_branch | |
| run: | | |
| set -euo pipefail | |
| VERSION="${{ steps.package_version.outputs.current_version }}" | |
| BRANCH="sync/main-${VERSION}" | |
| echo "sync_branch=${BRANCH}" >> "$GITHUB_OUTPUT" | |
| git fetch origin "${BRANCH}":refs/remotes/origin/tmp-sync-branch 2>/dev/null || true | |
| if git ls-remote --exit-code --heads origin "${BRANCH}" > /dev/null 2>&1; then | |
| echo "Branch ${BRANCH} already exists on origin, skip creating new sync branch." | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create and push sync/main-X.Y.Z branch | |
| if: steps.sync_branch.outputs.exists == 'false' | |
| run: | | |
| set -euo pipefail | |
| VERSION="${{ steps.package_version.outputs.current_version }}" | |
| BRANCH="${{ steps.sync_branch.outputs.sync_branch }}" | |
| git checkout main | |
| git pull --ff-only origin main | |
| git checkout -b "${BRANCH}" | |
| git push --no-verify origin "${BRANCH}" | |
| - name: Create Pull Request to develop | |
| if: steps.sync_branch.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| BRANCH="${{ steps.sync_branch.outputs.sync_branch }}" | |
| echo "Source branch: $BRANCH" | |
| # Check if PR already exists | |
| if gh pr list --base develop --head "$BRANCH" --state open --json number --limit 1 | grep -q '"number"'; then | |
| echo "PR from $BRANCH to develop already exists, skip creating." | |
| exit 0 | |
| fi | |
| TITLE="[Auto Sync] Sync the code from branch main to branch develop after release ${{ steps.package_version.outputs.current_version }}" | |
| BODY="Sync the code from branch main to branch develop after release ${{ steps.package_version.outputs.current_version }}" | |
| gh pr create --base develop --head "$BRANCH" --title "$TITLE" --body "$BODY" --reviewer xuefei1313 |