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
| # This workflow automatically creates a test branch from a release tag | |
| # For example, when release v1.40.0 is published, it creates test-v1.40.0 branch | |
| # Can also be triggered manually to create a test branch from any existing tag | |
| name: Create Test Branch from Release | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name to create test branch from (e.g., v1.40.0)' | |
| required: true | |
| type: string | |
| test_branch_name: | |
| description: 'Test branch name (optional, defaults to test-<tag_name>)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-test-branch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract tag name | |
| id: extract_tag | |
| run: | | |
| # Determine tag name based on trigger type | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| TAG_NAME=${{ inputs.tag_name }} | |
| if [ -n "${{ inputs.test_branch_name }}" ]; then | |
| TEST_BRANCH_NAME=${{ inputs.test_branch_name }} | |
| else | |
| TEST_BRANCH_NAME="test-${TAG_NAME}" | |
| fi | |
| else | |
| TAG_NAME=${{ github.event.release.tag_name }} | |
| TEST_BRANCH_NAME="test-${TAG_NAME}" | |
| fi | |
| echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT | |
| echo "test_branch_name=${TEST_BRANCH_NAME}" >> $GITHUB_OUTPUT | |
| echo "Creating test branch: ${TEST_BRANCH_NAME} from tag: ${TAG_NAME}" | |
| - name: Checkout release tag | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.extract_tag.outputs.tag_name }} | |
| fetch-depth: 0 | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Create and push test branch | |
| run: | | |
| TEST_BRANCH=${{ steps.extract_tag.outputs.test_branch_name }} | |
| # Check if branch already exists remotely | |
| if git ls-remote --heads origin ${TEST_BRANCH} | grep -q ${TEST_BRANCH}; then | |
| echo "Branch ${TEST_BRANCH} already exists remotely. Skipping creation." | |
| exit 0 | |
| fi | |
| # Create and push the test branch | |
| git checkout -b ${TEST_BRANCH} | |
| git push origin ${TEST_BRANCH} | |
| echo "Successfully created and pushed branch: ${TEST_BRANCH}" | |
| - name: Summary | |
| run: | | |
| echo "✅ Test branch created successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Tag**: \`${{ steps.extract_tag.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Test Branch**: \`${{ steps.extract_tag.outputs.test_branch_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch URL**: https://github.com/${{ github.repository }}/tree/${{ steps.extract_tag.outputs.test_branch_name }}" >> $GITHUB_STEP_SUMMARY |