Update sites.yaml version on branch creation #3
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: Update sites.yaml version on branch creation | |
| on: | |
| create: | |
| branches: | |
| - 'release-*' # 只在 release 分支触发 | |
| jobs: | |
| update-sites: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from branch name | |
| id: extract_version | |
| run: | | |
| BRANCH_NAME="${GITHUB_REF_NAME}" | |
| VERSION=$(echo "$BRANCH_NAME" | sed -E 's/release-([0-9]+\.[0-9]+)/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Update sites.yaml | |
| run: | | |
| VERSION="${{ steps.extract_version.outputs.version }}" | |
| echo "Setting version to $VERSION" | |
| sed -i -E "s/(version:).*/\1 \"$VERSION\"/" sites.yaml | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add sites.yaml | |
| git commit -m "Update sites.yaml version to ${{ steps.extract_version.outputs.version }}" || echo "No changes to commit" | |
| - name: Push changes | |
| run: | | |
| git push origin HEAD:${GITHUB_REF_NAME} |