Bump flake8 from 7.2.0 to 7.3.0 #138
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
| on: | |
| pull_request: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get branch name | |
| id: branch-name | |
| uses: tj-actions/branch-names@v9 | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch main branch | |
| run: | | |
| git fetch origin main | |
| MAIN_VERSION=$(git show origin/main:VERSION) | |
| echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV | |
| - name: Determine new version | |
| id: determine-version | |
| env: | |
| # Safely get title (avoid injection attacks) | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| # Set Title environment flag to false | |
| TITLE_FLAG="false" | |
| VERSION_TYPE="false" | |
| echo "PR Title: $PR_TITLE" | |
| if [[ "$PR_TITLE" == *"[FEATURE]"* ]]; then | |
| VERSION_TYPE="minor" | |
| echo "PR set to FEATURE updating minor version" | |
| TITLE_FLAG="true" | |
| else | |
| VERSION_TYPE="patch" | |
| echo "PR set to BUGFIX updating patch version" | |
| TITLE_FLAG="true" | |
| fi | |
| # If Feature or Bugfix update the version | |
| if [[ "$TITLE_FLAG" == "true" ]]; then | |
| # Abort script if version file missing | |
| if [[ ! -f VERSION ]]; then | |
| echo "VERSION file not found! Aborting." | |
| exit 1 | |
| fi | |
| # Get branch version | |
| BRANCH_VERSION=$(cat VERSION) | |
| echo "Branch Version: $BRANCH_VERSION" | |
| # Get the main version and split into VERSION_PARTS | |
| IFS='.' read -r -a VERSION_PARTS <<< "$MAIN_VERSION" | |
| if [[ "$VERSION_TYPE" == "minor" ]]; then | |
| VERSION_PARTS[1]=$((VERSION_PARTS[1]+1)) | |
| VERSION_PARTS[2]=0 | |
| elif [[ "$VERSION_TYPE" == "patch" ]]; then | |
| VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) | |
| fi | |
| NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| echo "New Version: " $NEW_VERSION | |
| fi | |
| # Set variables to global environment variables for later | |
| echo "TITLE_FLAG=$TITLE_FLAG" >> $GITHUB_ENV | |
| echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV | |
| echo "VERSION_TYPE=$VERSION_TYPE" >> $GITHUB_ENV | |
| echo "BRANCH_VERSION=$BRANCH_VERSION" >> $GITHUB_ENV | |
| - name: Comment on PR with no spam | |
| uses: actions/github-script@v8 | |
| env: | |
| TITLE_FLAG: ${{ env.TITLE_FLAG }} | |
| PR_TITLE: ${{ env.PR_TITLE }} | |
| NEW_VERSION: ${{ env.NEW_VERSION }} | |
| MAIN_VERSION: ${{ env.MAIN_VERSION }} | |
| BRANCH_VERSION: ${{ env.BRANCH_VERSION }} | |
| VERSION_TYPE: ${{ env.VERSION_TYPE }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| // Retrieve variables from the environment | |
| const titleFlag = process.env.TITLE_FLAG; | |
| const prNumber = context.issue.number; | |
| const prTitle = process.env.PR_TITLE; | |
| const newVersion = process.env.NEW_VERSION; | |
| const currentVersion = process.env.MAIN_VERSION; | |
| const branchVersion = process.env.BRANCH_VERSION; | |
| const versionType = process.env.VERSION_TYPE; | |
| // Prepare the message based on the title flag | |
| let prBody; | |
| if (titleFlag === "false") { | |
| prBody = ` | |
| ### 🚨 ARM Version Bot | |
| **PR Title:** \`${prTitle}\` | |
| > ❌ **No valid version flag found.** | |
| > | |
| > Please include either \`[FEATURE]\` or \`[BUGFIX]\` in your PR title to trigger auto-increment. | |
| > | |
| > _Update the PR title and re-run the workflow._ | |
| `; | |
| } else { | |
| prBody = ` | |
| ### ✅ ARM Version Bot | |
| **PR Title:** \`${prTitle}\` | |
| | Current Version | Required Version | PR Branch Version | Release Type | | |
| | :-------------: | :--------------: | :---------------: | :----------: | | |
| | \`${currentVersion}\` | \`${newVersion}\` | \`${branchVersion}\` | \`${versionType}\` | | |
| ${ | |
| currentVersion !== newVersion | |
| ? "> ⚠️ **Warning:** The required version ${newVersion} does not match the current version ${currentVersion} inside your VERSION file. | |
| This PR will not be merged unless you bump the version number.\n" | |
| : "" | |
| } | |
| --- | |
| _This comment was generated automatically by the ARM Version Bot._ | |
| `; | |
| } | |
| // Get existing comments | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| per_page: 100 | |
| }); | |
| // Check for existing version bot comments | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('Version Bot') | |
| ); | |
| // Generate PR comment if not already there | |
| if (botComment) { | |
| // Check if comment aligns with expected output, otherwise update | |
| if (botComment.body !== prBody) { | |
| // Update the existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: prBody | |
| }); | |
| console.log('Updated existing Version Bot comment.'); | |
| } else { | |
| console.log('No comment update needed.'); | |
| } | |
| } else { | |
| // Creating new comment, no previous comments found | |
| console.log('Creating new comment'); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: prBody | |
| }) | |
| } |