This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
forked from fastapi/fastapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tiangolo/master
fastapi 0.63.0 merge
- Loading branch information
Showing
241 changed files
with
21,937 additions
and
1,356 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
blank_issues_enabled: false |
2 changes: 1 addition & 1 deletion
2
.github/actions/get-artifact/Dockerfile → ...ons/comment-docs-preview-in-pr/Dockerfile
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Comment Docs Preview in PR | ||
description: Comment with the docs URL preview in the PR | ||
author: Sebastián Ramírez <[email protected]> | ||
inputs: | ||
token: | ||
description: Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }} | ||
required: true | ||
deploy_url: | ||
description: The deployment URL to comment in the PR | ||
required: true | ||
runs: | ||
using: docker | ||
image: Dockerfile |
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,70 @@ | ||
import logging | ||
import sys | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import httpx | ||
from github import Github | ||
from github.PullRequest import PullRequest | ||
from pydantic import BaseModel, BaseSettings, SecretStr, ValidationError | ||
|
||
github_api = "https://api.github.com" | ||
|
||
|
||
class Settings(BaseSettings): | ||
github_repository: str | ||
github_event_path: Path | ||
github_event_name: Optional[str] = None | ||
input_token: SecretStr | ||
input_deploy_url: str | ||
|
||
|
||
class PartialGithubEventHeadCommit(BaseModel): | ||
id: str | ||
|
||
|
||
class PartialGithubEventWorkflowRun(BaseModel): | ||
head_commit: PartialGithubEventHeadCommit | ||
|
||
|
||
class PartialGithubEvent(BaseModel): | ||
workflow_run: PartialGithubEventWorkflowRun | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
settings = Settings() | ||
logging.info(f"Using config: {settings.json()}") | ||
g = Github(settings.input_token.get_secret_value()) | ||
repo = g.get_repo(settings.github_repository) | ||
try: | ||
event = PartialGithubEvent.parse_file(settings.github_event_path) | ||
except ValidationError as e: | ||
logging.error(f"Error parsing event file: {e.errors()}") | ||
sys.exit(0) | ||
use_pr: Optional[PullRequest] = None | ||
for pr in repo.get_pulls(): | ||
if pr.head.sha == event.workflow_run.head_commit.id: | ||
use_pr = pr | ||
break | ||
if not use_pr: | ||
logging.error( | ||
f"No PR found for hash: {event.workflow_run.head_commit.id}" | ||
) | ||
sys.exit(0) | ||
github_headers = { | ||
"Authorization": f"token {settings.input_token.get_secret_value()}" | ||
} | ||
url = f"{github_api}/repos/{settings.github_repository}/issues/{use_pr.number}/comments" | ||
logging.info(f"Using comments URL: {url}") | ||
response = httpx.post( | ||
url, | ||
headers=github_headers, | ||
json={ | ||
"body": f"📝 Docs preview for commit {use_pr.head.sha} at: {settings.input_deploy_url}" | ||
}, | ||
) | ||
if not (200 <= response.status_code <= 300): | ||
logging.error(f"Error posting comment: {response.text}") | ||
sys.exit(1) | ||
logging.info("Finished") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
FROM python:3.7 | ||
|
||
RUN pip install httpx PyGithub "pydantic==1.5.1" "pyyaml>=5.3.1,<6.0.0" | ||
|
||
COPY ./app /app | ||
|
||
CMD ["python", "/app/main.py"] |
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,13 @@ | ||
name: "Generate FastAPI People" | ||
description: "Generate the data for the FastAPI People page" | ||
author: "Sebastián Ramírez <[email protected]>" | ||
inputs: | ||
token: | ||
description: 'User token, to read the GitHub API. Can be passed in using {{ secrets.ACTION_TOKEN }}' | ||
required: true | ||
standard_token: | ||
description: 'Default GitHub Action token, used for the PR. Can be passed in using {{ secrets.GITHUB_TOKEN }}' | ||
required: true | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
Oops, something went wrong.