-
Notifications
You must be signed in to change notification settings - Fork 4
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
Import Github API to trigger workflow and fetch issues #41
Merged
Merged
Changes from 4 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ZENHUB_APIKEY | ||
ZENHUB_APIKEY | ||
GITHUB_TOKEN | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true | ||
} | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getOctokit } from '~/githubClient' | ||
|
||
async function getIssue (owner: string, repo: string, teamName: string) { | ||
const issues = await getOctokit().request('GET /repos/{owner}/{repo}/issues', { | ||
owner, | ||
repo, | ||
labels: teamName | ||
}) | ||
return issues.data[0] | ||
} | ||
|
||
export default getIssue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import getIssue from './getIssues' | ||
import { getOctokit } from '~/githubClient' | ||
async function getWorkflows (owner: string, repo: string, runID: number) { | ||
const result = await getOctokit().request( | ||
'GET /repos/{owner}/{repo}/actions/runs/{runID}', | ||
{ | ||
owner, | ||
repo, | ||
runID | ||
} | ||
) | ||
|
||
return result | ||
} | ||
|
||
async function waitForSuccessStatus ( | ||
owner: string, | ||
repo: string, | ||
runID: number, | ||
teamName: string | ||
) { | ||
let attempts = 0 | ||
const maxAttempts: number = 20 | ||
const delay: number = 10000 | ||
while (attempts < maxAttempts) { | ||
console.log('hello') | ||
const res = await getWorkflows(owner, repo, runID) | ||
const status = res.data.status | ||
console.log('status' + status) | ||
if (status === 'completed') { | ||
const issues = await getIssue(owner, repo, teamName) | ||
return issues | ||
} | ||
|
||
// Wait for a specified delay before checking again | ||
await new Promise(resolve => setTimeout(resolve, delay)) | ||
|
||
attempts++ | ||
} | ||
|
||
throw new Error( | ||
"Timeout: The status did not become 'success' within the specified number of attempts." | ||
) | ||
} | ||
|
||
export default waitForSuccessStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getOctokit } from '~/githubClient' | ||
|
||
async function runWorkflow (owner: string, repo: string, runID: number) { | ||
return await getOctokit().request( | ||
'POST /repos/{owner}/{repo}/actions/runs/{runID}/rerun', | ||
{ | ||
owner, | ||
repo, | ||
runID | ||
} | ||
) | ||
} | ||
|
||
export default runWorkflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ enum BoardName { | |
NAMETEAMSPACE = 'names-team-board', | ||
} | ||
|
||
export default BoardName | ||
export default BoardName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enum runJob { | ||
ENTITIES = 7066220176, | ||
} | ||
|
||
export default runJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enum workflowRun { | ||
OWNER = 'bcgov', | ||
REPO = 'metrics-report', | ||
} | ||
|
||
export default workflowRun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Octokit } from 'octokit' | ||
export function getOctokit () { | ||
const config = useRuntimeConfig() | ||
const octokit = new Octokit({ | ||
auth: config.public.githubToken | ||
}) | ||
return octokit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are you pulling GITHUB_TOKEN from? If you want this variable to be in gcbrun, you will need to add it here:
sbc-producthub/apps/application-status/devops/cloudbuild-pr.yaml
Line 10 in 069ac47
If you also want it to be loaded in the builds from 1password, you will need to add it here https://github.com/bcgov/sbc-producthub/blob/main/apps/application-status/vaults.env probably something like GITHUB_TOKEN ="op://API/$APP_ENV/github/GITHUB_TOKEN"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did not have the permission to add the key on GCP or 1password yet, therefore, gcbrun build is currently failing to display, and the same for dev build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent you direct message about the key value, as I don't know which value you are using