diff --git a/.github/scripts/generate-changelog.sh b/.github/scripts/generate-changelog.sh index fd84ee4f..e6300128 100755 --- a/.github/scripts/generate-changelog.sh +++ b/.github/scripts/generate-changelog.sh @@ -137,7 +137,7 @@ while IFS= read -r commit_line; do fi CATEGORIES["$CATEGORY"]=1 - COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' + COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by @$GITHUB_USERNAME"$'\n' else COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM))"$'\n' fi @@ -165,7 +165,7 @@ while IFS= read -r commit_line; do CATEGORIES["$CATEGORY"]=1 COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix - COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' + COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by @$GITHUB_USERNAME"$'\n' else COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix @@ -196,7 +196,7 @@ while IFS= read -r commit_line; do CATEGORIES["$CATEGORY"]=1 COMMIT_TITLE=${COMMIT_MSG#*: } # Remove the type prefix - COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE (${HASH:0:7}) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' + COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE (${HASH:0:7}) by @$GITHUB_USERNAME"$'\n' else # Fallback to git author name if no GitHub username found AUTHOR_NAME=$(git show -s --format='%an' "$HASH") diff --git a/.github/workflows/update-stable.yml b/.github/workflows/update-stable.yml index b1944876..f7341c43 100644 --- a/.github/workflows/update-stable.yml +++ b/.github/workflows/update-stable.yml @@ -88,6 +88,8 @@ jobs: id: changelog env: NEW_VERSION: ${{ steps.bump_version.outputs.new_version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: .github/scripts/generate-changelog.sh - name: Get the latest commit hash and version tag diff --git a/app/utils/selectStarterTemplate.ts b/app/utils/selectStarterTemplate.ts index 0e779e1c..4a7536da 100644 --- a/app/utils/selectStarterTemplate.ts +++ b/app/utils/selectStarterTemplate.ts @@ -2,6 +2,7 @@ import ignore from 'ignore'; import type { ProviderInfo } from '~/types/model'; import type { Template } from '~/types/template'; import { STARTER_TEMPLATES } from './constants'; +import Cookies from 'js-cookie'; const starterTemplateSelectionPrompt = (templates: Template[]) => ` You are an experienced developer who helps people choose the best starter template for their projects. @@ -116,14 +117,20 @@ const getGitHubRepoContent = async ( const baseUrl = 'https://api.github.com'; try { + const token = Cookies.get('githubToken') || import.meta.env.VITE_GITHUB_ACCESS_TOKEN; + + const headers: HeadersInit = { + Accept: 'application/vnd.github.v3+json', + }; + + // Add your GitHub token if needed + if (token) { + headers.Authorization = 'token ' + token; + } + // Fetch contents of the path const response = await fetch(`${baseUrl}/repos/${repoName}/contents/${path}`, { - headers: { - Accept: 'application/vnd.github.v3+json', - - // Add your GitHub token if needed - Authorization: 'token ' + import.meta.env.VITE_GITHUB_ACCESS_TOKEN, - }, + headers, }); if (!response.ok) { @@ -156,10 +163,7 @@ const getGitHubRepoContent = async ( } else if (item.type === 'file') { // Fetch file content const fileResponse = await fetch(item.url, { - headers: { - Accept: 'application/vnd.github.v3+json', - Authorization: 'token ' + import.meta.env.VITE_GITHUB_ACCESS_TOKEN, - }, + headers, }); const fileData: any = await fileResponse.json(); const content = atob(fileData.content); // Decode base64 content