Refactor cleanup logic in containerScanner (AST-106461) #18
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: Release Containers resolver Go module new version | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| tag-and-release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Get and Format the PR Title | |
| id: get_pr_title | |
| run: | | |
| pr_title="${{ github.event.pull_request.title }}" | |
| # Use grep with regex to extract the format (AST-000) from the title | |
| formatted_title=$(echo "$pr_title" | grep -oE "\(AST-[0-9]+\)") | |
| # If formatted_title is empty, set a default value or handle the error | |
| if [ -z "$formatted_title" ]; then | |
| echo "No valid format found in PR title." | |
| exit 1 | |
| fi | |
| echo "formatted_title=$formatted_title" >> $GITHUB_ENV | |
| - name: Fetch All Tags | |
| run: git fetch --tags | |
| - name: Get Latest Tag | |
| id: get_tag | |
| run: | | |
| latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
| echo "tag=${latest_tag}" >> $GITHUB_ENV | |
| - name: Bump Patch Version | |
| id: bump | |
| uses: cbrgm/semver-bump-action@308d9e8a2d31333339de793a169b3c0254a49013 #v1.0.33 | |
| with: | |
| current-version: ${{ env.tag }} | |
| bump-level: patch | |
| - name: Create a new tag | |
| run: | | |
| git config --global user.name "github-actions" | |
| git config --global user.email "[email protected]" | |
| new_tag=${{ steps.bump.outputs.new_version }} | |
| git tag $new_tag -m "${{ env.formatted_title }}" | |
| git push origin $new_tag | |
| - name: Create release from tag | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
| with: | |
| tag_name: ${{ steps.bump.outputs.new_version }} | |
| release_name: Release ${{ steps.bump.outputs.new_version }} | |
| body: ${{ steps.get_pr_title.outputs.pr_title }} | |
| draft: false | |
| prerelease: false |