GitHub Action
Quote - README
There is a short tutorial with enough steps for you to get started with this not-so-useful GitHub Action. Check that out here.
If you want to get an in-depth idea of the usage of this action, please follow the below points.
- You need to update the markdown file(.md) with 2 comments. You can refer to here for updating it.
- Optional You'll need a GitHub API Token with
repo
scope from here if you're running the action for a non-profile repository.- You can use this example to work it out.
- You can follow any one example below according to your needs to get started!
- It is better to run the Action on your Profile Repository since you won't be needing a GitHub Access Token!
- Check this to see available options while creating a workflow for this action.
If you are facing a GithubException "Resource not accessible by integration", you may want to check your repository permissions or GitHub token permissions.
For repository permissions (Thank you @jaborjkath for bringing this to my attention): To enable read and write permissions from the relevant repository settings (top right corner) → Actions (left navigation bar) → General → Workflow permissions section. You can find more information here.
For GitHub token permissions you can refer here.
Add a comment to your README.md
like this:
<!--STARTS_HERE_QUOTE_README-->
<!--ENDS_HERE_QUOTE_README-->
You can place these 2 lines anywhere you want quotes/facts to be displayed.
If you're executing the workflow on your Profile Repository (<username>/<username>
)
You wouldn't need a GitHub Access Token since GitHub Actions already makes one for you.
Please follow the steps below:
- Go to your
<username>/<username>/actions
, hitNew workflow
, thenset up a workflow yourself
, delete all the default content github made for you. - Copy the following code and paste it to your new workflow you created at step 1, commit the workflow and name it whatever you like !
name: Update Quote Readme
on:
workflow_dispatch:
schedule:
# Runs at 2 UTC everyday
- cron: "0 2 * * *"
jobs:
update-readme:
name: Update Quote README
runs-on: ubuntu-latest
steps:
- uses: siddharth2016/quote-readme@main
- There is another tag as well you can use,
OPTION
that would allow you to specify what you want either a quote or a fact to be displayed, by default it isboth
. Check examples for more. - Add a comment to your
README.md
like this:
<!--STARTS_HERE_QUOTE_README-->
<!--ENDS_HERE_QUOTE_README-->
- Go to Workflows menu (mentioned in step 1), click
Update Quote Readme
, clickRun workflow
. - Go to your profile page, you will be able to see a random quote/fact wherever you placed this comment on README.
If you're executing the workflow on another repo other than (<username>/<username>
)
You'll need to get a GitHub Access Token with a repo
scope.
You need to save the GitHub API Token in the repository secrets. You can find that in the Settings of your Repository.
- Go to your
<username>/<differentrepo>/actions
, hitNew workflow
, thenset up a workflow yourself
, delete all the default content github made for you. - Copy the following code and paste it to your new workflow you created at step 1, commit the workflow with whatever name you like !
name: Update Quote Readme
on:
workflow_dispatch:
schedule:
# Runs at 2 UTC everyday
- cron: "0 2 * * *"
jobs:
update-readme:
name: Update Quote README
runs-on: ubuntu-latest
steps:
- uses: siddharth2016/quote-readme@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
REPOSITORY: <username>/<differentrepo> # No need to mention this if workflow present in current non profile repo.
- There is another tag as well you can use,
OPTION
that would allow you to specify what you want either a quote or a fact to be displayed, by default it isboth
. Check examples for more. - Add a comment to your
README.md
like this:
<!--STARTS_HERE_QUOTE_README-->
<!--ENDS_HERE_QUOTE_README-->
- Go to Workflows menu (mentioned in step 1), click
Update Quote Readme
, clickRun workflow
. - Go to your profile page, you will be able to see a random quote/fact wherever you placed this comment on README.
- If you want to use this action for a README that is not present in current workflow repository.
- uses: siddharth2016/update-readme-image@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Needed if README repository is not profile repo
REPOSITORY: <username>/<differentrepo>
Using REPOSITORY
will change README present in that repository head.
For example, if your workflow is present in <username>/repo1
and you want to update README present in <username>/repo2
, then assign REPOSITORY
to <username>/repo2
in workflow at <username>/repo1
.
- You can specify a commit message to override the default "Update with quote-readme".
- uses: siddharth2016/update-readme-image@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Needed if README repository is not profile repo
REPOSITORY: <username>/<differentrepo> # Needed if README repository is not current repo
COMMIT_MESSAGE: <your-commit-message> # default - Update with quote-readme
- You can also choose if you only want either a random
quote
or a randomfunfact
to appear on your readme, by default it isboth
.
- uses: siddharth2016/update-readme-image@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Needed if README repository is not profile repo
REPOSITORY: <username>/<differentrepo> # Needed if README repository is not current repo
COMMIT_MESSAGE: <your-commit-message> # default - Update with quote-readme
OPTION: both # default - both, can be one of (quote, funfact, both), if 'both' then will display either a quote or a fact
To run tests simply execute the following in the directory containing main.py
:
python -m unittest discover