Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Description

This PR implements an automated workflow to detect and commit localization string updates from building the Aspire.ProjectTemplates project.

Changes

  • Created .github/workflows/update-templates-localization-strings.yml
    • Runs daily at 05:00 UTC via cron schedule or on manual workflow dispatch
    • Restores dependencies and builds the ProjectTemplates project
    • Automatically creates or updates a PR with changes to src/Aspire.ProjectTemplates/templates/*templatestrings.*.json files only
    • Labels PR with area-templates and area-engineering-systems
    • Uses dotnet/actions-create-pull-request action with path filters to include only templatestrings files

How It Works

  1. Scheduled Execution: Runs daily to check for localization updates
  2. Build ProjectTemplates: Runs restore and builds the ProjectTemplates project, which may update templatestrings files as part of the localization process
  3. Create PR: If any templatestrings files are modified, creates or updates a PR with those changes only using path filters
  4. Review & Merge: Maintainers can review and merge the automated PR

Benefits

  1. Automated Updates: Localization string updates are automatically detected and proposed via PRs
  2. Minimal Permissions: Uses standard PR creation permissions without requiring broad comment permissions
  3. Clear Attribution: Changes are isolated in dedicated automated PRs
  4. Reviewable: Maintainers can review changes before merging
  5. Non-blocking: Doesn't fail CI builds, just creates PRs for review when updates are needed
  6. Consistent Pattern: Follows the same approach as other automated update workflows in the repository

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No (Workflow will be tested via scheduled runs and manual dispatch)
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No
Original prompt

Update the repository build pipeline so that if any files in the path src/Aspire.ProjectTemplates/templates/templatestrings..json have been modified locally by the build (i.e., after invoking the build, the working directory has changed for these files), the build should fail immediately with a clear message. This enforces that builds do not leave uncommitted changes for these template string JSON files, ensuring consistency and reproducibility. The solution should work both for local developer builds and CI builds, and should provide helpful output identifying changed files if there is a failure.

This pull request was created as a result of the following prompt from Copilot chat.

Update the repository build pipeline so that if any files in the path src/Aspire.ProjectTemplates/templates/templatestrings..json have been modified locally by the build (i.e., after invoking the build, the working directory has changed for these files), the build should fail immediately with a clear message. This enforces that builds do not leave uncommitted changes for these template string JSON files, ensuring consistency and reproducibility. The solution should work both for local developer builds and CI builds, and should provide helpful output identifying changed files if there is a failure.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 5, 2025 18:43
- Added MSBuild target CheckTemplateStringsNotModified that runs after build
- Target uses PowerShell script to detect uncommitted changes to templatestrings files
- Build fails with clear error message if any templatestrings files are modified
- Includes instructions on how to fix the issue
- Works in both local and CI environments
- Committed the templatestrings file changes that were generated by the build

Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
- Removed MSBuild target from Aspire.ProjectTemplates.csproj
- Added check_templatestrings job to .github/workflows/tests.yml
- Check runs after build_packages job
- Added as dependency to Final Test Results job
- Uses bash script to check for modified templatestrings files
- Fails CI if any templatestrings files have uncommitted changes

Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
Copilot AI changed the title [WIP] Update build pipeline to fail on modified template strings Add CI check for uncommitted templatestrings modifications during build Nov 5, 2025
Copilot AI requested a review from sebastienros November 5, 2025 18:55
Copilot finished work on behalf of sebastienros November 5, 2025 18:55
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12707

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12707"

path: extension/out/aspire-extension.vsix

check_templatestrings:
name: Check templatestrings files not modified
Copy link
Member

Choose a reason for hiding this comment

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

@copilot this should be conditioned to run only for PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 619fe78. Added condition if: ${{ github.event_name == 'pull_request' }} to the job so it only runs for PRs.

# Check failed - there are modified files
echo ""
echo "================================================================================"
Copy link
Member

Choose a reason for hiding this comment

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

@copilot This whole message should be posted as a comment on the PR too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 619fe78. The error message is now captured in GITHUB_OUTPUT and posted as a PR comment using github-script action when the check fails. The message is formatted as markdown for better readability.

… failure

- Added condition to run check_templatestrings only for pull_request events
- Modified check to capture error message in GITHUB_OUTPUT
- Added github-script step to post error message as PR comment on failure
- Error message formatted as markdown for better readability in PR comments

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI requested a review from radical November 5, 2025 19:58
Copilot finished work on behalf of radical November 5, 2025 19:58
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check for modified templatestrings files
Copy link
Member

Choose a reason for hiding this comment

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

@copilot before this step, run ./restore.sh and then ./dotnet.sh build ${{ github.workspace }}/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj /bl:${{ github.workspace }}/artifacts/log/Debug/BuildTemplates.binlog. This build would make any localization updates if needed, which would allow the next step to run correctly. Also, add a step at the end to upload the binlog .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit ec284ce. Added:

  1. ./restore.sh step before the check
  2. Build step: ./dotnet.sh build ${{ github.workspace }}/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj /bl:${{ github.workspace }}/artifacts/log/Debug/BuildTemplates.binlog
  3. Upload binlog step at the end (runs always with if: always())

- Added ./restore.sh step before checking files
- Added build step for ProjectTemplates project with binlog output
- Added step to upload binlog artifact (always runs)
- This ensures the build runs and can modify templatestrings before checking

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI requested a review from radical November 5, 2025 20:33
Copilot finished work on behalf of radical November 5, 2025 20:33
check_templatestrings:
name: Check templatestrings files not modified
runs-on: ubuntu-latest
needs: build_packages
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
needs: build_packages

@copilot the dependency is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d003d3a. Removed the needs: build_packages dependency since the job now runs its own restore and build steps.

The check_templatestrings job runs its own restore and build steps, so it doesn't need to wait for build_packages to complete. This allows the check to run in parallel with other jobs.

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI requested a review from radical November 5, 2025 20:43
Copilot finished work on behalf of radical November 5, 2025 20:43
@radical
Copy link
Member

radical commented Nov 5, 2025

@copilot the check fails with:

SyntaxError: Unexpected identifier 'src'
    at new AsyncFunction (<anonymous>)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:35424:16)
    at main (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:35522:26)
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:35497:1
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:35553:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:35556:12)
    at Module._compile (node:internal/modules/cjs/loader:1521:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
Error: Unhandled error: SyntaxError: Unexpected identifier 'src'

The error message was being directly embedded in a JavaScript template literal, which caused syntax errors when the message contained backticks or other special characters. Now passing it through the env context and accessing via process.env.ERROR_MESSAGE.

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot the check fails with:

SyntaxError: Unexpected identifier 'src'

...

Fixed in commit 280ad5b. The error was caused by embedding the error message directly in a JavaScript template literal. When the message contained backticks (from the markdown formatting), it broke the JavaScript syntax. Now passing the message through the env context and accessing it via process.env.ERROR_MESSAGE.

Copilot finished work on behalf of radical November 5, 2025 21:17
@radical
Copy link
Member

radical commented Nov 5, 2025

@copilot we need to rework this because posting a comment from the PR needs permissions which are too broad. Instead do this:

  • create a new workflow similar to update-github-models.yml called update-templates-localization-strings.yml

  • Follow the steps from this PR to build the src/Aspire.ProjectTemplates project

  • Then open a PR with changes matching files src/Aspire.ProjectTemplates/templates/*templatestrings.*.json only

  • And drop the changes to tests.yml .

- Reverted all changes to .github/workflows/tests.yml
- Created new workflow .github/workflows/update-templates-localization-strings.yml
- New workflow builds ProjectTemplates and creates PR with templatestrings.*.json changes
- Runs on schedule (daily) and manual dispatch
- Uses dotnet/actions-create-pull-request with path-filters for templatestrings files only

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot we need to rework this because posting a comment from the PR needs permissions which are too broad. Instead do this:

  • create a new workflow similar to update-github-models.yml called `u...

Done in commit e139d4a. Created new workflow update-templates-localization-strings.yml that:

  • Runs on schedule (daily) and workflow_dispatch
  • Builds ProjectTemplates to trigger localization updates
  • Creates automated PR with changes to *templatestrings.*.json files only using path-filters
  • Reverted all changes to tests.yml

Copilot AI changed the title Add CI check for uncommitted templatestrings modifications during build Add automated workflow for templates localization strings updates Nov 5, 2025
Copilot finished work on behalf of radical November 5, 2025 21:44
@radical radical closed this Nov 5, 2025
@radical radical reopened this Nov 5, 2025
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 5, 2025
@radical radical marked this pull request as ready for review November 5, 2025 23:09
Copilot AI review requested due to automatic review settings November 5, 2025 23:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new GitHub Actions workflow that automatically generates and updates template localization strings on a daily schedule. The workflow builds the ProjectTemplates project to regenerate localization files and creates/updates a pull request with any changes.

Key Changes:

  • Adds automated daily workflow to update template localization strings
  • Configures PR creation with appropriate labels and targeting for localization file changes

run: ./restore.sh

- name: Build ProjectTemplates to update localization strings
run: ./dotnet.sh build ${{ github.workspace }}/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj /bl:${{ github.workspace }}/artifacts/log/Debug/BuildTemplates.binlog
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The binlog path hardcodes 'Debug' configuration, but the build command doesn't specify a configuration. This could cause inconsistency if the build defaults to a different configuration. Consider either adding -c Debug to the build command or using a configuration-agnostic path like ${{ github.workspace }}/artifacts/log/BuildTemplates.binlog.

Suggested change
run: ./dotnet.sh build ${{ github.workspace }}/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj /bl:${{ github.workspace }}/artifacts/log/Debug/BuildTemplates.binlog
run: ./dotnet.sh build ${{ github.workspace }}/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj -c Debug /bl:${{ github.workspace }}/artifacts/log/Debug/BuildTemplates.binlog

Copilot uses AI. Check for mistakes.
title: "[Automated] Update templates localization strings"
body: "Auto-generated update of template localization strings (templatestrings.*.json files)."
path-filters: |
src/Aspire.ProjectTemplates/templates/*templatestrings.*.json
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The path filter pattern uses a single wildcard which may not match files in subdirectories. According to the custom coding guidelines, localization files match the pattern */localize/templatestrings.*.json. The current pattern templates/*templatestrings.*.json may not correctly capture files in the localize subdirectories. Consider using src/Aspire.ProjectTemplates/templates/*/localize/templatestrings.*.json to match the actual file structure.

Suggested change
src/Aspire.ProjectTemplates/templates/*templatestrings.*.json
src/Aspire.ProjectTemplates/templates/*/localize/templatestrings.*.json

Copilot uses AI. Check for mistakes.
@radical radical enabled auto-merge (squash) November 7, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants