From 436696b11bf2dadb905fbc8aedde491cd5b992d7 Mon Sep 17 00:00:00 2001 From: Ollama Date: Mon, 9 Mar 2026 21:03:55 +0000 Subject: [PATCH] Add workflow to auto-update issue templates with releases Adds a GitHub Actions workflow that automatically updates the OpensourcePOS Version dropdown in bug report and feature request templates when new releases are published. Fixes #4317 --- .github/workflows/update-issue-templates.yml | 72 ++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/update-issue-templates.yml diff --git a/.github/workflows/update-issue-templates.yml b/.github/workflows/update-issue-templates.yml new file mode 100644 index 000000000..f101a6264 --- /dev/null +++ b/.github/workflows/update-issue-templates.yml @@ -0,0 +1,72 @@ +name: Update Issue Templates + +on: + release: + types: [published] + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + +jobs: + update-templates: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Fetch releases and update templates + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Fetch releases from GitHub API + RELEASES=$(gh api repos/${{ github.repository }}/releases --jq '.[].tag_name' | head -n 10) + + # Create temporary file with options + OPTIONS_FILE=$(mktemp) + echo " - development (unreleased)" >> "$OPTIONS_FILE" + while IFS= read -r release; do + echo " - opensourcepos $release" >> "$OPTIONS_FILE" + done <<< "$RELEASES" + + update_template() { + local template="$1" + local template_path=".github/ISSUE_TEMPLATE/$template" + + # Find the line numbers for the OpensourcePOS Version dropdown + start_line=$(grep -n "label: OpensourcePOS Version" "$template_path" | cut -d: -f1) + + if [ -z "$start_line" ]; then + echo "Could not find OpensourcePOS Version in $template" + return 1 + fi + + # Find the options section and default line + options_start=$((start_line + 3)) + default_line=$(grep -n "default:" "$template_path" | awk -F: -v opts="$options_start" '$1 > opts {print $1; exit}') + + # Create new template file + head -n $((options_start - 1)) "$template_path" > "${template_path}.new" + cat "$OPTIONS_FILE" >> "${template_path}.new" + tail -n +$default_line "$template_path" >> "${template_path}.new" + mv "${template_path}.new" "$template_path" + + echo "Updated $template" + } + + update_template "bug report.yml" + update_template "feature_request.yml" + + - name: Commit and push changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add .github/ISSUE_TEMPLATE/*.yml + if git diff --staged --quiet; then + echo "No changes to commit" + else + git commit -m "Update issue templates with latest releases [skip ci]" + git push + fi \ No newline at end of file