Skip to content

Update sites.yaml version on branch creation #3

Update sites.yaml version on branch creation

Update sites.yaml version on branch creation #3

Workflow file for this run

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}