Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update code to support @octokit/request v9 and @octokit/graphql v8 #3705

Closed
Closed
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
19 changes: 14 additions & 5 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- if: steps.should_run.outputs.shouldrun == 'true'
name: Await Netlify Preview
uses: jakepartusch/wait-for-netlify-action@f1e137043864b9ab9034ae3a5adc1c108e3f1a48 #version 1.4 https://github.com/JakePartusch/wait-for-netlify-action/releases/tag/v1.4
uses: jakepartusch/[email protected]
id: netlify
with:
site_name: asyncapi-website
Expand All @@ -48,15 +48,15 @@ jobs:
- if: steps.should_run.outputs.shouldrun == 'true'
name: Lighthouse Audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826 #version 10.1 https://github.com/treosh/lighthouse-ci-action/releases/tag/10.1.0
uses: treosh/lighthouse-ci-action@v10.1.0
with:
urls: |
https://deploy-preview-$PR_NUMBER--asyncapi-website.netlify.app/
https://deploy-preview-${{ github.event.pull_request.number }}--asyncapi-website.netlify.app/
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true
env:
PR_NUMBER: ${{ github.event.pull_request.number}}
PR_NUMBER: ${{ github.event.pull_request.number }}

- if: steps.should_run.outputs.shouldrun == 'true'
name: Lighthouse Score Report
Expand Down Expand Up @@ -87,9 +87,18 @@ jobs:
- if: steps.should_run.outputs.shouldrun == 'true'
name: LightHouse Statistic Comment
id: lighthouse_statistic_comment
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # version 2.8 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.8.0
uses: marocchino/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.lighthouse_score_report.outputs.comment }}

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove Extraneous Marker Causing YAML Parse Error

Line 96 appears to contain an extraneous marker (a lone ~ or similar) which is triggering a YAML parsing error ("did not find expected key"). Please remove this line to resolve the syntax issue.

🧰 Tools
🪛 actionlint (1.7.4)

96-96: could not parse as YAML: yaml: line 96: did not find expected key

(syntax-check)

-name: Upload artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: lighthouse-report
path: ./path/to/lighthouse-report # Ensure this path is correct
retention-days: 5
continue-on-error: true
15 changes: 6 additions & 9 deletions netlify/functions/github_discussions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Handler, HandlerEvent } from '@netlify/functions';
import type { GraphQlQueryResponseData } from '@octokit/graphql';
import { graphql } from '@octokit/graphql';

const repositoryID: string =
Expand All @@ -25,22 +24,20 @@ const handler: Handler = async function (event: HandlerEvent) {
const { title, feedback } = JSON.parse(event.body || '');

try {
// eslint-disable-next-line function-paren-newline
const createDiscussion: GraphQlQueryResponseData = await graphql(
`mutation {
const createDiscussion = await graphql(
{
query: `mutation {
createDiscussion(input:{repositoryId:"${repositoryID}", categoryId:"${categoryID}", title:"${title}", body:"${feedback}"}){
discussion{
url
}
}
}`,
{
owner: 'asyncapi',
repo: 'community',
headers: {
authorization: `token ${process.env.GITHUB_TOKEN_CREATE_DISCUSSION}`
authorization: `Bearer ${process.env.GITHUB_TOKEN_CREATE_DISCUSSION}`
}
});
}
);
const { url } = createDiscussion.createDiscussion.discussion;

return {
Expand Down
2 changes: 1 addition & 1 deletion netlify/functions/save-discussion-background/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function toTitleCase(title: string): string {
export async function fetchGraphql(query: string): Promise<any> {
const parameters = {
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`,
authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM! Authorization header updated to OAuth 2.0 standard format.

The change from token to Bearer prefix aligns with the OAuth 2.0 standard and the requirements of @octokit/graphql v8.


🏁 Script executed:

#!/bin/bash
# Description: Verify that all GitHub API calls use Bearer token format

# Test: Search for any remaining token-based auth. Expect: No occurrences.
rg -i 'authorization.*token\s+\$'

Length of output: 545


FYI: Inconsistencies detected – further updates required for consistent OAuth 2.0 token usage.

LGTM for the changes in netlify/functions/save-discussion-background/helpers.ts where the Authorization header was updated to use the Bearer prefix in line with OAuth 2.0 and @octokit/graphql v8 requirements. However, our verification script found several other locations still using the old token prefix for the Authorization header. Please review and update the following files for consistency, unless these occurrences are intentionally exempted:

  • netlify/edge-functions/serve-definitions.ts: Contains originalRequest.headers.set('Authorization', \token ${GITHUB_TOKEN}`);`
  • tests/tools/extract-tools-github.test.js: Uses authorization: \token ${process.env.GITHUB_TOKEN}``
  • scripts/dashboard/build-dashboard.js: Contains multiple instances of authorization: \token ${process.env.GITHUB_TOKEN}``
  • scripts/tools/extract-tools-github.js: Uses authorization: \token ${process.env.GITHUB_TOKEN}``

Please address these inconsistencies to ensure a uniform authentication method across the codebase.

},
};
return await graphql(query, parameters);
Expand Down
Loading