Skip to content

Commit

Permalink
Merge pull request #110 from yumemi-inc/feature/disenable-copilot-on-…
Browse files Browse the repository at this point in the history
…use-template

Feature/disenable copilot on use template
  • Loading branch information
Yamasaki-pan961 committed Feb 2, 2024
2 parents c47d8e3 + 9630355 commit 4d36ce8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/actions/cleanup-copilot-settings/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Cleanup Copilot Settings"
description: "Cleanup Copilot settings in settings.json file"

inputs:
settings-json-path:
description: "Path to the settings.json file"
default: ".vscode/settings.json"
temp-json-path:
description: "Path to the temp.json file"
default: "temp.json"

runs:
using: "composite"
steps:
- name: Set up Node.js
uses: actions/setup-node@v4

- name: Install jq
# https://github.com/dcarbone/install-jq-action
uses: dcarbone/install-jq-action@v2.1.0

- name: Install strip-json-comments-cli
# https://www.npmjs.com/package/strip-json-comments-cli
run: npm install -g strip-json-comments-cli
shell: sh

- name: Strip comments from settings.json
run: strip-json-comments ${{ inputs.settings-json-path }} > ${{ inputs.temp-json-path }}
shell: sh

- name: Edit Json
# https://github.com/jqlang/jq
run: >
jq -n -f ${{ inputs.temp-json-path }} |
jq '
."github.copilot.enable" |= {"*": false} |
."github.copilot.editor.enableCodeActions" |= false |
."github.copilot.editor.enableAutoCompletions" |= false
'
> ${{ inputs.settings-json-path }}
shell: sh

- name: Remove temp
run: rm ${{ inputs.temp-json-path }}
shell: sh

- name: Show settings.json
run: cat ${{ inputs.settings-json-path }}
shell: sh
38 changes: 38 additions & 0 deletions .github/workflows/template-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Template Cleanup

on:
push:
branches:
- main

jobs:
template-cleanup:
runs-on: ubuntu-latest

permissions:
contents: write
issues: write

timeout-minutes: 10
if: github.event.repository.name != 'flutter-mobile-project-template'
steps:
# https://github.com/actions/checkout
- name: Fetch sources
uses: actions/checkout@v4

- name: Cleanup Copilot Settings
uses: ./.github/actions/cleanup-copilot-settings

- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Template cleanup"
# https://github.com/ad-m/github-push-action
- name: Push changes
uses: ad-m/github-push-action@v0.8.0
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"dart-code.flutter",
"blaugold.melos-code",
"djbkwon.flutter-dependency-docs",
"esbenp.prettier-vscode",
]
}
13 changes: 12 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// GitHubのテンプレート機能使用してリポジトリを作った際に、このファイルのコメントは削除されます
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
"dart.sdkPath": ".fvm/flutter_sdk/bin/cache/dart-sdk",
Expand All @@ -10,8 +11,10 @@
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.dart": "$(capture).g.dart, $(capture).freezed.dart",
"pubspec.yaml": "pubspec.lock, pubspec_overrides.yaml",
"pubspec.yaml": "pubspec.lock, pubspec_overrides.yaml"
},
// GitHubのテンプレート機能使用してリポジトリを作った際に、
// copilotの設定は無効化されるように上書きするワークフローが実行されます
"github.copilot.enable": {
"*": false,
"markdown": true,
Expand All @@ -21,4 +24,12 @@
},
"github.copilot.editor.enableCodeActions": true,
"github.copilot.editor.enableAutoCompletions": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.associations": {
"*.json": "json"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
4 changes: 4 additions & 0 deletions docs/COPILOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ VSCodeがサポートしている言語一覧
https://code.visualstudio.com/docs/languages/identifiers


> [!NOTE]
> すでにこの設定はプロジェクトに適応されてますが、
> GitHubのテンプレート機能使用してリポジトリを作った際に、
> 設定は無効化されるように上書きするワークフローが実行されます
### Xcode
1. [Copilot for Xcode](https://github.com/intitni/CopilotForXcode)をインストールする
2. READMEに従い、Copilot for Xcodeを有効化する
Expand Down

0 comments on commit 4d36ce8

Please sign in to comment.