diff options
author | Jordan Cook <jordan.cook.git@proton.me> | 2022-07-19 17:35:18 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook.git@proton.me> | 2022-07-19 18:25:36 -0500 |
commit | 4727acc914b4c227d43eaaaa06dd167374864086 (patch) | |
tree | 8590d0ac38bd46e118a70876876027de548a4ba8 | |
parent | 229f61225e0cde4be64242e713ae34b80572afb8 (diff) | |
download | requests-cache-4727acc914b4c227d43eaaaa06dd167374864086.tar.gz |
Add example with GitHub Actions
-rw-r--r-- | docs/examples.md | 19 | ||||
-rw-r--r-- | examples/github_actions.yml | 27 |
2 files changed, 46 insertions, 0 deletions
diff --git a/docs/examples.md b/docs/examples.md index fdf593c..3beba85 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -175,6 +175,25 @@ The following scripts can also be found in the ``` ::: +### Using with GitHub Actions +This example shows how to use requests-cache with [GitHub Actions](https://docs.github.com/en/actions). +Key points: +* Create the cache file within the CI project directory +* You can use [actions/cache](https://github.com/actions/cache) to persist the cache file across + workflow runs + * You can use a constant cache key within this action to let requests-cache handle expiration + + +:::{dropdown} Example +:animate: fade-in-slide-down +:color: primary +:icon: file-code + +[github_actions.yml](https://github.com/requests-cache/requests-cache/blob/main/examples/github_actions.yml) +```{literalinclude} ../examples/github_actions.yml +``` +::: + ### Converting an old cache ```{include} ../examples/convert_cache.py :start-line: 2 diff --git a/examples/github_actions.yml b/examples/github_actions.yml new file mode 100644 index 0000000..dffd045 --- /dev/null +++ b/examples/github_actions.yml @@ -0,0 +1,27 @@ +name: Test requests-cache with GitHub Actions + +on: + push: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + # Persist the SQLite file created by requests-cache across workflow runs + - id: cache + uses: actions/cache@v3 + with: + path: example_cache.sqlite + key: none + + # Install and run basic requests-cache example + - run: pip install '.' + - run: python examples/basic_sessions.py + - run: python examples/basic_sessions.py + - run: test -f example_cache.sqlite && echo 'Cache file created' || echo 'Cache file missing' |