Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/actions/code-style/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ inputs:
description: "Operation mode: fix or check"
required: false
default: "check"
token:
description: "GitHub token for authentication"
required: true
commit:
description: "Commit?"
required: false
default: false
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -42,8 +43,12 @@ runs:
uses: ./.github/actions/code-style/using-sorter
with:
mode: ${{ inputs.mode }}
- name: Check namespaces
uses: ./.github/actions/code-style/namespace-fixer
with:
mode: check
- name: Commit & push changes
if: ${{ inputs.mode == 'fix' }}
if: ${{ inputs.commit }}
shell: bash
run: |
git config user.name "github-actions"
Expand Down
28 changes: 15 additions & 13 deletions .github/actions/code-style/header-fixer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ runs:
with:
fetch-depth: 0
- name: Process C# file headers
if: always()
shell: bash
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
run: |
if [ -n "${{ github.event.pull_request }}" ]; then
FILES=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" -- '*.cs')
# Determine files to process: changed in PR or all .cs in src/
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ -f "$GITHUB_EVENT_PATH" ]; then
BASE_SHA=$(jq -r .pull_request.base.sha < "$GITHUB_EVENT_PATH")
HEAD_SHA=$(jq -r .pull_request.head.sha < "$GITHUB_EVENT_PATH")
FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '*.cs' || true)
else
# Fallback to all .cs files when not a pull_request event
FILES=$(find . -type f -name '*.cs')
# Fallback to all .cs files under src/
FILES=$(find src -type f -name '*.cs')
fi
# If no files, skip
if [ -z "$FILES" ]; then
echo "No C# files to process"
exit 0
fi
ERR=0
for file in $FILES; do
Expand Down Expand Up @@ -56,11 +66,3 @@ runs:
fi
done
exit $ERR
- name: Commit & push changes
if: ${{ inputs.mode == 'fix' }}
shell: bash
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git diff --quiet || (git commit -m "chore: automatically fixed file headers" && git push)
8 changes: 0 additions & 8 deletions .github/actions/code-style/namespace-fixer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,3 @@ runs:
fi
done
exit $ERR
- name: Commit & push changes
if: ${{ inputs.mode == 'fix' }}
shell: bash
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git diff --quiet || (git commit -m "chore: automatically fix namespaces" && git push)
8 changes: 0 additions & 8 deletions .github/actions/code-style/trailing-whitespace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,3 @@ runs:
fi
done
exit $ERR
- name: Commit & push changes
if: ${{ inputs.mode == 'fix' }}
shell: bash
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git diff --quiet || (git commit -m "chore: automatically fixed trailing whitespace" && git push)
8 changes: 0 additions & 8 deletions .github/actions/code-style/using-sorter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,3 @@ runs:
done
# fail if any check error
exit $ERR
- name: Commit & push changes
if: ${{ inputs.mode == 'fix' }}
shell: bash
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git diff --quiet || (git commit -m "chore: automatically sort using directives" && git push)
183 changes: 99 additions & 84 deletions .github/workflows/chore-version-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,107 +14,122 @@ name: 🔄 Update Version Badge
on:
workflow_dispatch:
push:
branches:
branches:
- release/*
- main
- dev
- release/*
paths:
- 'Solution.props'

permissions:
contents: write
pull-requests: write

jobs:
paths-check:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.filter.outputs.version }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
version:
- Solution.props
update-badge:
needs: paths-check
runs-on: ubuntu-latest
if: >
startsWith(github.ref, 'refs/heads/release/') ||
needs.paths-check.outputs.version_changed == 'true'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
ref: ${{ github.ref }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Get target branch
run: |
TARGET_BRANCH="${{ github.ref_name }}"
echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV
echo "BADGE_BRANCH=docs/update-version-badge-$TARGET_BRANCH" >> $GITHUB_ENV
- name: Get target branch
run: |
TARGET_BRANCH="${{ github.ref_name }}"
echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV
echo "BADGE_BRANCH=docs/update-version-badge-$TARGET_BRANCH" >> $GITHUB_ENV

- name: Delete existing badge branches
continue-on-error: true
run: |
echo "Current branches before deletion:"
git branch -a

# Delete remote branch if it exists
git push origin --delete ${{ env.BADGE_BRANCH }} || true

echo "Branches after deletion:"
git branch -a
- name: Delete existing badge branches
continue-on-error: true
run: |
echo "Current branches before deletion:"
git branch -a
# Delete remote branch if it exists
git push origin --delete ${{ env.BADGE_BRANCH }} || true
echo "Branches after deletion:"
git branch -a

- name: Delete existing PR
continue-on-error: true
run: |
# Get PR number if it exists
PR_NUMBER=$(gh pr list --base ${{ env.TARGET_BRANCH }} --head ${{ env.BADGE_BRANCH }} --json number --jq '.[0].number')
if [ ! -z "$PR_NUMBER" ]; then
echo "Found existing PR #$PR_NUMBER, closing it"
gh pr close $PR_NUMBER --delete-branch
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete existing PR
continue-on-error: true
run: |
# Get PR number if it exists
PR_NUMBER=$(gh pr list --base ${{ env.TARGET_BRANCH }} --head ${{ env.BADGE_BRANCH }} --json number --jq '.[0].number')
if [ ! -z "$PR_NUMBER" ]; then
echo "Found existing PR #$PR_NUMBER, closing it"
gh pr close $PR_NUMBER --delete-branch
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update version badge
id: update-badge
uses: ./.github/actions/documentation/update-badges
with:
branch: ${{ github.ref_name }}
- name: Update version badge
id: update-badge
uses: ./.github/actions/documentation/update-badges
with:
branch: ${{ github.ref_name }}

- name: Check if badges need updating
id: check-badges
run: |
if [[ "${{ steps.update-badge.outputs.badges-changed }}" == "false" ]]; then
echo "Badges are already up to date. No changes needed."
echo "::notice::Badges are already up to date with the current version. Workflow execution stopped."
exit 0
else
echo "Badges need to be updated. Continuing workflow."
fi
shell: bash
- name: Check if badges need updating
id: check-badges
run: |
if [[ "${{ steps.update-badge.outputs.badges-changed }}" == "false" ]]; then
echo "Badges are already up to date. No changes needed."
echo "::notice::Badges are already up to date with the current version. Workflow execution stopped."
exit 0
else
echo "Badges need to be updated. Continuing workflow."
fi
shell: bash

- name: Create and push branch
if: steps.update-badge.outputs.badges-changed == 'true'
run: |
echo "Creating new branch: ${{ env.BADGE_BRANCH }}"
git checkout -b ${{ env.BADGE_BRANCH }}

# Check if there are actual changes to commit
if [[ -n "$(git status --porcelain README.md)" ]]; then
echo "Changes detected in README.md, committing and pushing"
git add README.md
git commit -m "docs: update version badge for ${{ env.TARGET_BRANCH }}"
git push origin ${{ env.BADGE_BRANCH }}
echo "CHANGES_PUSHED=true" >> $GITHUB_ENV
else
echo "No actual changes detected in README.md despite badges-changed=true"
echo "This might indicate a parsing issue in the version-tools action"
echo "::warning::No changes to commit for README.md despite badges-changed=true"
echo "CHANGES_PUSHED=false" >> $GITHUB_ENV
fi
- name: Create and push branch
if: steps.update-badge.outputs.badges-changed == 'true'
run: |
echo "Creating new branch: ${{ env.BADGE_BRANCH }}"
git checkout -b ${{ env.BADGE_BRANCH }}
# Check if there are actual changes to commit
if [[ -n "$(git status --porcelain README.md)" ]]; then
echo "Changes detected in README.md, committing and pushing"
git add README.md
git commit -m "docs: update version badge for ${{ env.TARGET_BRANCH }}"
git push origin ${{ env.BADGE_BRANCH }}
echo "CHANGES_PUSHED=true" >> $GITHUB_ENV
else
echo "No actual changes detected in README.md despite badges-changed=true"
echo "This might indicate a parsing issue in the version-tools action"
echo "::warning::No changes to commit for README.md despite badges-changed=true"
echo "CHANGES_PUSHED=false" >> $GITHUB_ENV
fi

- name: Create PR
if: steps.update-badge.outputs.badges-changed == 'true' && env.CHANGES_PUSHED == 'true'
run: |
PR_TITLE="docs: update version badge for ${{ env.TARGET_BRANCH }} to ${{ steps.update-badge.outputs.version }}"
PR_BODY="This PR updates the version badge in the README.md to match the current version in Solution.props.
- name: Create PR
if: steps.update-badge.outputs.badges-changed == 'true' && env.CHANGES_PUSHED == 'true'
run: |
PR_TITLE="docs: update version badge for ${{ env.TARGET_BRANCH }} to ${{ steps.update-badge.outputs.version }}"
PR_BODY="This PR updates the version badge in the README.md to match the current version in Solution.props.

This is an automated PR created by the Update Version Badge workflow."

gh pr create --base ${{ env.TARGET_BRANCH }} --head ${{ env.BADGE_BRANCH }} --title "$PR_TITLE" --body "$PR_BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This is an automated PR created by the Update Version Badge workflow."
gh pr create --base ${{ env.TARGET_BRANCH }} --head ${{ env.BADGE_BRANCH }} --title "$PR_TITLE" --body "$PR_BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/release-1-milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 🏁 1 Prepare Release on Milestone Close

# Description: This workflow automatically prepares a release branch when a milestone is closed.
# It extracts the milestone title as the version number and compiles release notes from
# all issues and pull requests associated with the milestone.
#
# Triggers:
# - Automatically when a milestone is closed
#
# Permissions:
# - contents:write - Required to create GitHub releases
# - issues:read - Required to read issue information for release notes
# - pull-requests:read - Required to read PR information for release notes

on:
workflow_dispatch:
milestone:
types: [ closed ]

jobs:
release-preparation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: dev
- name: Set up Git user
run: |
git config user.name "github-actions"
git config user.email "action@github.com"
- name: Create release branch
run: git checkout -b release/${{ github.event.milestone.title }}
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch name derived directly from the milestone title may include spaces or special characters that are invalid in branch names; consider sanitizing the milestone title before using it to create the branch.

Suggested change
run: git checkout -b release/${{ github.event.milestone.title }}
run: |
sanitized_title=$(echo "${{ github.event.milestone.title }}" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '-' | tr -cd 'a-z0-9-')
git checkout -b release/${sanitized_title}

Copilot uses AI. Check for mistakes.
- name: Update version in Solution.props
uses: ./.github/actions/versioning/update-version
with:
new-version: ${{ github.event.milestone.title }}
- name: Include missing issues in changelog
uses: ./.github/actions/documentation/update-changelog-issues
with:
token: ${{ secrets.GITHUB_TOKEN }}
days-lookback: 90
- name: Update changelog section
uses: ./.github/actions/documentation/update-changelog
with:
action: create-release
version: ${{ github.event.milestone.title }}
- name: Fix code style
uses: ./.github/actions/code-style
with:
mode: fix
commit: false
- name: Commit and push changes
run: |
git add Solution.props CHANGELOG.md
git commit -m "chore: prepare release ${{ github.event.milestone.title }} with version update and code style fixes"
git push origin release/${{ github.event.milestone.title }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "chore: prepare release ${{ github.event.milestone.title }} with version update and code style fixes"
body: "This PR prepares the release for version ${{ github.event.milestone.title }} with version update and code style fixes:\n\n- Fixed header code style\n- Sorted usings\n- Removed trailing whitespace\n- Updated version in Solution.props\n- Updated changelog with closed-solved issues\n\nMILESTONE DESCRIPTION:\n${{ github.event.milestone.description }}"
base: dev
branch: release/${{ github.event.milestone.title }}
milestone: ${{ github.event.milestone.number }}
Comment on lines +22 to +66

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

Copilot Autofix

AI about 1 year ago

To fix the issue, we need to add a permissions block at the root of the workflow file. This block will define the minimal permissions required for the workflow to function correctly. Based on the workflow's actions, the following permissions are required:

  • contents: write to create and push changes to the release branch.
  • issues: read to read issue information for release notes.
  • pull-requests: write to create a pull request.

The permissions block should be added immediately after the name field in the workflow file.


Suggested changeset 1
.github/workflows/release-1-milestone.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/release-1-milestone.yml b/.github/workflows/release-1-milestone.yml
--- a/.github/workflows/release-1-milestone.yml
+++ b/.github/workflows/release-1-milestone.yml
@@ -1,2 +1,6 @@
 name: 🏁 1 Prepare Release on Milestone Close
+permissions:
+  contents: write
+  issues: read
+  pull-requests: write
 
EOF
@@ -1,2 +1,6 @@
name: 🏁 1 Prepare Release on Milestone Close
permissions:
contents: write
issues: read
pull-requests: write

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Loading
Loading