Library to sync git repository to Github Gists
Project description
Repo Gist Sync
A library to synchronize git repository to Github Gists
graph TD;
A(local machine)
A -->|push| B(Github repository)
B -->|Github Actions| C(Gists)
B -->|Github Actions| E(Gists)
B -->|Github Actions| F(Gists)
C --> D(Embeds)
E --> G(Embeds)
F --> H(Embeds)
C --> I(Embeds)
E --> J(Embeds)
F --> K(Embeds)
Installation
Install from PyPI.
pip install repo-gist-sync
Dependencies: requests
, click
Example
- Write the Code as follows:
get_user_id.py
#-- title: Get User's ID
#-- description: Code to retrieve user_id from username
#-- tags: python, medium_api, medium_api_py
# Import libraries
import os
from medium_api import Medium
#%%
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
#%%
# Create a `Medium` Object
medium = Medium(api_key)
#%%
# Get the `User` Object using "username" and print ID
user = medium.user(username="nishu-jain")
print(user.user_id)
get_user_id_output.txt
1985b61817c3
- Sync using
gistdirsync
CLI tool.
gistdirsync --auth-token $GIST_TOKEN --directory /path/to/folder
- Resulting Gist looks like this.
get_user_id.py
# Import libraries
import os
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Get the `User` Object using "username" and print ID
user = medium.user(username="nishu-jain")
print(user.user_id)
get_user_id_1.py
# Import libraries
import os
from medium_api import Medium
get_user_id_2.py
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
get_user_id_3.py
# Create a `Medium` Object
medium = Medium(api_key)
get_user_id_4.py
# Get the `User` Object using "username" and print ID
user = medium.user(username="nishu-jain")
print(user.user_id)
get_user_id_output.txt
1985b61817c3
Continuous Deployment with Github Actions
name: GIST CD on main branch and example directory change
on:
push:
paths:
- examples/**
jobs:
build:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install repo-gist-sync
run: pip install repo-gist-sync
- name: Use "gistsyncdir" on "examples" directory
run: gistdirsync --auth-token ${{ secrets.GIST_TOKEN }} --directory ./examples/
Features
- Supports python (
.py
) and shellscripts (.sh
) - Can write metadata in file itself
- Break the code in smaller snippets
- can save the output in the corresponding gist by naming the file as "filename_output.txt"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
repo-gist-sync-0.4.1.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for repo_gist_sync-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6866c25bcf9ae13cd8fcaa13813b3d78c0906f8bd45bbfd6f4e340965c8304a |
|
MD5 | 10ac1a1632c6c7f74159922937e9b034 |
|
BLAKE2b-256 | ae3462cbb9b5b29f41935b4458197453d3e41959c7f266ee6b92cd937ad09f2a |