Prompt Title: Versioning Action

Created 3 months ago
Votes 0
Views 63 times
0

Prompt Detail:

Sure, to create a GitHub Action that tags a new version in the master branch when a pull request titled with "Release" is merged, you'll need to write a workflow file. Here's a basic outline:

  1. Trigger: The action should be triggered on pull request events, specifically the closed event.
  2. Condition: Check if the pull request is merged and its title starts with "Release".
  3. Action: Create a new tag and push it to the repository.

Here's a sample .yml file for your GitHub Action:

yaml
name: Tag Release on: pull_request: types: [closed] branches: - master jobs: tag: runs-on: ubuntu-latest if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release') steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Git run: | git config --local user.email "[email protected]" git config --local user.name "GitHub Action" - name: Create Tag run: | PR_TITLE="${{ github.event.pull_request.title }}" VERSION=${PR_TITLE#"Release "} git tag $VERSION git push origin $VERSION

This workflow does the following:

  • Activates when a pull request to the master branch is closed.
  • Checks if the pull request is merged and if its title starts with "Release".
  • Configures Git with a default user and email.
  • Extracts the version number from the pull request title (assuming the title is like "Release v1.0.0") and creates a tag.
  • Pushes the tag to the repository.

Make sure to adapt the script to suit your version naming convention and repository structure. Also, consider adding error handling or additional logging as needed for your use case.

avatar
Asher
Shared 1 prompt
Created 3 months ago

Leave a Comment

Related Tag Prompts

0
0
GitHub Actions with Comments.
1 year ago 2023-03-30 13:07:36 Félix Paradis
0
0
Git Tagging Types.
1 year ago 2023-03-31 09:44:34 murali
0
0
0
0
Sync GitHub Accounts.
11 months ago 2023-05-12 02:34:38 Shiva Aryal
0
0
Link GitHub Account with Windows
10 months ago 2023-06-18 00:01:14 Rohan