feat: support custom repository

This commit is contained in:
saltbo 2020-08-23 14:04:56 +08:00
parent aaff45b1d4
commit 8a3ea94195
3 changed files with 6 additions and 8 deletions

View File

@ -108,7 +108,7 @@ jobs:
with: with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
USERNAME: <username> # optional, it will automatically use the username of the owner of the repository who's executing the workflow. REPOSITORY: <username/username> # optional, By default, it will automatically use the repository who's executing the workflow.
``` ```
## Tests ## Tests
@ -131,7 +131,6 @@ Since this project is contained all within one file, 'main.py'. You can simply a
with: with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
USERNAME: <username>
SHOW_TITLE: true SHOW_TITLE: true
``` ```
@ -153,7 +152,6 @@ YAML 7 mins ░░░░░░░░░░░░░░░░
with: with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
USERNAME: <username>
COMMIT_MESSAGE: Updated the Readme COMMIT_MESSAGE: Updated the Readme
``` ```

View File

@ -12,9 +12,9 @@ inputs:
description: 'Your Wakatime API Key' description: 'Your Wakatime API Key'
required: true required: true
USERNAME: REPOSITORY:
description: 'Your GitHub username' description: 'Your GitHub repository'
default: ${{ github.repository_owner }} default: ${{ github.repository }}
required: false required: false
SHOW_TITLE: SHOW_TITLE:

View File

@ -14,7 +14,7 @@ START_COMMENT = '<!--START_SECTION:waka-->'
END_COMMENT = '<!--END_SECTION:waka-->' END_COMMENT = '<!--END_SECTION:waka-->'
listReg = f"{START_COMMENT}[\\s\\S]+{END_COMMENT}" listReg = f"{START_COMMENT}[\\s\\S]+{END_COMMENT}"
user = os.getenv('INPUT_USERNAME') repository = os.getenv('INPUT_REPOSITORY')
waka_key = os.getenv('INPUT_WAKATIME_API_KEY') waka_key = os.getenv('INPUT_WAKATIME_API_KEY')
ghtoken = os.getenv('INPUT_GH_TOKEN') ghtoken = os.getenv('INPUT_GH_TOKEN')
show_title = os.getenv("INPUT_SHOW_TITLE") show_title = os.getenv("INPUT_SHOW_TITLE")
@ -88,7 +88,7 @@ def generate_new_readme(stats: str, readme: str) -> str:
if __name__ == '__main__': if __name__ == '__main__':
g = Github(ghtoken) g = Github(ghtoken)
try: try:
repo = g.get_repo(f"{user}/{user}") repo = g.get_repo(repository)
except GithubException: except GithubException:
print("Authentication Error. Try saving a GitHub Token in your Repo Secrets or Use the GitHub Actions Token, which is automatically used by the action.") print("Authentication Error. Try saving a GitHub Token in your Repo Secrets or Use the GitHub Actions Token, which is automatically used by the action.")
sys.exit(1) sys.exit(1)