diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5523d3c..323c3a9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,7 +4,7 @@ # Order is important: the last matching pattern has the highest precedence # These owners will be the default owners for everything -* @cloudposse-github-actions/engineering @cloudposse-github-actions/engineering/contributors +* @cloudposse-github-actions/engineering @cloudposse-github-actions/contributors # Cloud Posse must review any changes to Makefiles **/Makefile @cloudposse-github-actions/engineering diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml deleted file mode 100644 index 2f90b94..0000000 --- a/.github/workflows/test-positive.yml +++ /dev/null @@ -1,193 +0,0 @@ -name: Test Action - -on: - workflow_dispatch: - inputs: - test_tag: - description: "Tag to test with" - required: false - default: "test-v1.0.0" - -jobs: - test-lightweight-tag: - runs-on: ubuntu-latest - env: - TAG_REF: test-lightweight-v1.0.0 - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Create test lightweight tag - run: | - git tag test-lightweight-v1.0.0 - git push origin test-lightweight-v1.0.0 - - - name: Test action with lightweight tag - id: test_lightweight - uses: ./ - with: - tag_ref: ${{ env.TAG_REF }} - branch: test-branch-lightweight-${{ env.TAG_REF }} - update_if_exists: "false" - - - name: Verify outputs - run: | - echo "Branch name: ${{ steps.test_lightweight.outputs.branch_name }}" - echo "Branch URL: ${{ steps.test_lightweight.outputs.branch_url }}" - echo "Created: ${{ steps.test_lightweight.outputs.created }}" - - # Verify branch was created - if [ "${{ steps.test_lightweight.outputs.created }}" != "true" ]; then - echo " Expected created=true for new branch" - exit 1 - fi - - if [ "${{ steps.test_lightweight.outputs.branch_name }}" != "test-branch-lightweight-${{ env.TAG_REF }}" ]; then - echo " Unexpected branch name" - exit 1 - fi - - test-annotated-tag: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Create test annotated tag - run: | - git config user.name "Test Bot" - git config user.email "test@example.com" - git tag -a test-annotated-v1.0.0 -m "Test annotated tag" - git push origin test-annotated-v1.0.0 - - - name: Test action with annotated tag - id: test_annotated - uses: ./ - with: - tag_ref: test-annotated-v1.0.0 - branch: test-branch-annotated - - - name: Verify outputs - run: | - echo "Branch name: ${{ steps.test_annotated.outputs.branch_name }}" - echo "Branch URL: ${{ steps.test_annotated.outputs.branch_url }}" - echo "Created: ${{ steps.test_annotated.outputs.created }}" - - test-update-existing: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Create test tag - run: | - git config user.name "Test Bot" - git config user.email "test@example.com" - git tag test-update-v1.0.0 - git push origin test-update-v1.0.0 - - - name: First run - create branch - id: first_run - uses: ./ - with: - tag_ref: test-update-v1.0.0 - branch: test-branch-update - - - name: Second run - update branch - id: second_run - uses: ./ - with: - tag_ref: test-update-v1.0.0 - branch: test-branch-update - update_if_exists: "true" - - - name: Third run - should update (update_if_exists=true) - id: third_run - uses: ./ - with: - tag_ref: test-update-v1.0.0 - branch: test-branch-update - update_if_exists: "true" - - - name: Verify behavior - run: | - # First run should create - if [ "${{ steps.first_run.outputs.created }}" != "true" ]; then - echo " First run should have created branch" - exit 1 - fi - - # Second run should skip - if [ "${{ steps.second_run.outputs.created }}" != "false" ]; then - echo " Second run should not have created branch" - exit 1 - fi - - # Third run should update (not create) - if [ "${{ steps.third_run.outputs.created }}" != "false" ]; then - echo " Third run should not have created branch (update only)" - exit 1 - fi - - test-error-handling: - runs-on: ubuntu-latest - env: - TAG_REF: non-existent-tag-v999.999.999 - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test with non-existent tag - id: test_missing_tag - uses: ./ - continue-on-error: true - with: - tag_ref: ${{ env.TAG_REF }} - branch: test-error-${{ env.TAG_REF }} - - - name: Verify error handling - run: | - if [ "${{ steps.test_missing_tag.outcome }}" != "failure" ]; then - echo " Action should have failed with non-existent tag" - exit 1 - fi - echo "Error handling works correctly" - - cleanup: - runs-on: ubuntu-latest - needs: - [ - test-lightweight-tag, - test-annotated-tag, - test-update-existing, - test-error-handling, - ] - if: always() - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Cleanup test tags and branches - run: | - git config user.name "Test Bot" - git config user.email "test@example.com" - - # Delete test tags - git push --delete origin test-lightweight-v1.0.0 || true - git push --delete origin test-annotated-v1.0.0 || true - git push --delete origin test-update-v1.0.0 || true - - # Delete test branches - git push --delete origin test-release@test-lightweight-v1.0.0 || true - git push --delete origin test-release@test-annotated-v1.0.0 || true - git push --delete origin test-update@test-update-v1.0.0 || true diff --git a/README.md b/README.md index f27a55c..a1f6d63 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# github-action-typescript-template +# Create Branch from a Specific Tag -Latest ReleaseSlack Community +Latest ReleaseSlack Community @@ -30,21 +30,101 @@ --> -Template repo for GitHub Actions written in TypeScript +This action creates a new branch from a specific tag. ## Introduction -This repo is a template for GitHub Actions written in TypeScript. +This action creates a new branch from a specific tag. + +This is a fork of [satya-500's create a branch from a tag action](https://github.com/satya-500/create-branch-from-tag) ## Usage -Use this repository as a template in your own GitHub Action project to get started. + +create branch from tag + ```yaml + - name: creating rc branch + uses: cloudposse-github-actions/create-branch-from-tag@v1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: release + tag: tags/v0.0.7 + ``` + + create branch from specific ref (branch) + ```yaml + - name: creating rc branch + uses: cloudposse-github-actions/create-branch-from-tag@v1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: release + tag: test + ``` + + Full Job Example (Workflow Dispatch as a shared reusable workflow) + ```yaml + on: + workflow_call: + inputs: + runs-on: + description: "The runner labels on which jobs should run on" + required: false + type: string + default: '["self-hosted"]' + organization: + description: "Repository owner organization (e.g. 'acme' for repo acme/example)" + required: true + type: string + repository: + description: "Repository name (e.g. 'example' for repo acme/example)" + required: true + type: string + tag: + description: "The semantic version tag of the release (e.g. 'v1.1.0')" + required: true + type: string + outputs: + branch-name: + description: "Branch name" + value: ${{ jobs.create-branch.outputs.branch-name }} + + permissions: + id-token: write + contents: write + + jobs: + create-branch: + name: build + runs-on: ${{ fromJSON(inputs.runs-on) }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Parse Semver + id: parse-semver + uses: booxmedialtd/ws-action-parse-semver@v1 + with: + input_string: ${{ inputs.tag }} + + - name: Create Release Branch + uses: cloudposse-github-actions/create-branch-from-tag@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # The following can easily just be 'release/${{ inputs.tag }}', however it is left as is + # in case the tag needs to be manipulated. For example: + # 'release/${{ steps.parse-semver.outputs.major }}.${{ steps.parse-semver.outputs.minor }}.x' + branch: release/${{ steps.parse-semver.outputs.fullversion }} + from: tags/${{ inputs.tag }} + ``` @@ -56,29 +136,20 @@ Use this repository as a template in your own GitHub Action project to get start | Name | Description | Default | Required | |------|-------------|---------|----------| -| milliseconds | input description here | 200 | true | +| branch | The branch to create | release | false | +| from | Provide the tag number ex:- v0.0.7 or branch name i.e develop | N/A | true | - ## Related Projects Check out these related projects. -## References - -For additional context, refer to some of these links. - -- [github-actions-workflows](https://github.com/cloudposse/github-actions-workflows) - Reusable workflows for different types of projects -- [example-github-action-release-workflow](https://github.com/cloudposse/example-github-action-release-workflow) - Example application with complicated release workflow - - - ## ✨ Contributing @@ -86,16 +157,10 @@ This project is under active development, and we encourage contributions from ou -Many thanks to our outstanding contributors: - - - - - -For πŸ› bug reports & feature requests, please use the [issue tracker](https://github.com/cloudposse/github-action-typescript-template/issues). +For πŸ› bug reports & feature requests, please use the [issue tracker](https://github.com/cloudposse-github-actions/create-branch-from-tag/issues). In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. - 1. Review our [Code of Conduct](https://github.com/cloudposse/github-action-typescript-template/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md). + 1. Review our [Code of Conduct](https://github.com/cloudposse-github-actions/create-branch-from-tag/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md). 2. **Fork** the repo on GitHub 3. **Clone** the project to your own machine 4. **Commit** changes to your own branch @@ -106,16 +171,16 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. ### 🌎 Slack Community -Join our [Open Source Community](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-typescript-template&utm_content=slack) on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. +Join our [Open Source Community](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-github-actions/create-branch-from-tag&utm_content=slack) on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. ### πŸ“° Newsletter -Sign up for [our newsletter](https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-typescript-template&utm_content=newsletter) and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. +Sign up for [our newsletter](https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-github-actions/create-branch-from-tag&utm_content=newsletter) and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β€” and usually a 5-minute read. -### πŸ“† Office Hours +### πŸ“† Office Hours -[Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-typescript-template&utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q&A_ that you can’t find anywhere else. +[Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse-github-actions/create-branch-from-tag&utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q&A_ that you can’t find anywhere else. It's **FREE** for everyone! ## License @@ -157,6 +222,6 @@ All other trademarks referenced herein are the property of their respective owne Copyright Β© 2017-2025 [Cloud Posse, LLC](https://cpco.io/copyright) -README footer +README footer -Beacon +Beacon