-
Notifications
You must be signed in to change notification settings - Fork 89
Add action typing #250
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
base: main
Are you sure you want to change the base?
Add action typing #250
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Check Action Typing | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
Vampire marked this conversation as resolved.
Show resolved
Hide resolved
|
||
jobs: | ||
check_action_typing: | ||
name: Check Action Typing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check Action Typing | ||
uses: typesafegithub/github-actions-typing@v2 | ||
Vampire marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit concerned about the long-term maintenance of these types and requiring this action's maintainers to keep them up to date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, for the permissions I added the same update generation logic that is used for the For the others, yes, you would have to maintain them. Unless you constantly add and remove inputs or outputs (other than the permissions which are generated), there should not be much additional effort hopefully, and the added action makes sure you don't forget to update them and have a valid format. And even if you very often change inputs / outputs, it is just adding it to that file too to define the type, so hopefully even then not a significant additional effort. :-) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,321 @@ | ||
# See https://github.com/typesafegithub/github-actions-typing | ||
inputs: | ||
app-id: | ||
type: string | ||
|
||
private-key: | ||
type: string | ||
|
||
owner: | ||
type: string | ||
|
||
repositories: | ||
type: list | ||
separator: "\n" | ||
list-item: | ||
type: string | ||
|
||
skip-token-revoke: | ||
type: boolean | ||
|
||
github-api-url: | ||
type: string | ||
|
||
# <START GENERATED PERMISSIONS TYPES> | ||
permission-actions: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-administration: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-checks: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-codespaces: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-contents: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-dependabot-secrets: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-deployments: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-email-addresses: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-environments: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-followers: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-git-ssh-keys: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-gpg-keys: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-interaction-limits: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-issues: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-members: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-metadata: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-administration: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-announcement-banners: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-copilot-seat-management: | ||
type: enum | ||
allowed-values: | ||
- "write" | ||
|
||
permission-organization-custom-org-roles: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-custom-properties: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
- "admin" | ||
|
||
permission-organization-custom-roles: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-events: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
|
||
permission-organization-hooks: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-packages: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-personal-access-token-requests: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-personal-access-tokens: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-plan: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
|
||
permission-organization-projects: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
- "admin" | ||
|
||
permission-organization-secrets: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-self-hosted-runners: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-organization-user-blocking: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-packages: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-pages: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-profile: | ||
type: enum | ||
allowed-values: | ||
- "write" | ||
|
||
permission-pull-requests: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-repository-custom-properties: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-repository-hooks: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-repository-projects: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
- "admin" | ||
|
||
permission-secret-scanning-alerts: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-secrets: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-security-events: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-single-file: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-starring: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-statuses: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-team-discussions: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-vulnerability-alerts: | ||
type: enum | ||
allowed-values: | ||
- "read" | ||
- "write" | ||
|
||
permission-workflows: | ||
type: enum | ||
allowed-values: | ||
- "write" | ||
|
||
# <END GENERATED PERMISSIONS TYPES> | ||
|
||
outputs: | ||
token: | ||
type: string | ||
|
||
installation-id: | ||
type: integer | ||
|
||
app-slug: | ||
type: string |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,13 +30,36 @@ const permissionsInputs = Object.entries(appPermissionsSchema.properties) | |||||
description: "${description}"`; | ||||||
}, ""); | ||||||
|
||||||
const actionsYamlContent = await readFile("action.yml", "utf8"); | ||||||
const actionYamlContent = await readFile("action.yml", "utf8"); | ||||||
|
||||||
// In the action.yml file, replace the content between the `<START GENERATED PERMISSIONS INPUTS>` and `<END GENERATED PERMISSIONS INPUTS>` comments with the new content | ||||||
const updatedActionsYamlContent = actionsYamlContent.replace( | ||||||
const updatedActionYamlContent = actionYamlContent.replace( | ||||||
/(?<=# <START GENERATED PERMISSIONS INPUTS>)(.|\n)*(?=# <END GENERATED PERMISSIONS INPUTS>)/, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider extracting the complex regex pattern used in the replace method into a well-named constant or helper function to improve readability and maintainability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
permissionsInputs + "\n " | ||||||
); | ||||||
|
||||||
await writeFile("action.yml", updatedActionsYamlContent, "utf8"); | ||||||
await writeFile("action.yml", updatedActionYamlContent, "utf8"); | ||||||
console.log("Updated action.yml with new permissions inputs"); | ||||||
|
||||||
const permissionsTypes = Object.entries(appPermissionsSchema.properties) | ||||||
.sort((a, b) => a[0].localeCompare(b[0])) | ||||||
.reduce((result, [key, value]) => { | ||||||
const permissionAccessValues = value.enum.map((p) => ` - "${p}"`).reduce((result, p) => `${result}\n${p}`); | ||||||
return `${result} | ||||||
permission-${key.replace(/_/g, "-")}: | ||||||
type: enum | ||||||
allowed-values: | ||||||
${permissionAccessValues} | ||||||
`; | ||||||
}, ""); | ||||||
|
||||||
const actionTypesYamlContent = await readFile("action-types.yml", "utf8"); | ||||||
|
||||||
// In the action-types.yml file, replace the content between the `<START GENERATED PERMISSIONS TYPES>` and `<END GENERATED PERMISSIONS TYPES>` comments with the new content | ||||||
const updatedActionTypesYamlContent = actionTypesYamlContent.replace( | ||||||
/(?<=# <START GENERATED PERMISSIONS TYPES>)(.|\n)*(?=# <END GENERATED PERMISSIONS TYPES>)/, | ||||||
permissionsTypes + "\n " | ||||||
); | ||||||
|
||||||
await writeFile("action-types.yml", updatedActionTypesYamlContent, "utf8"); | ||||||
console.log("Updated action-types.yml with new permissions types"); |
Uh oh!
There was an error while loading. Please reload this page.