|
|
(16 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| Github is a website that provides free public hosting of opensource projects. | | Github is a website that provides free public hosting of [[git]] repositories.<br> |
| It also provides other features like documentation hosting, issue tracking, | | It also provides other features like documentation hosting, issue tracking etc. |
| amongst other things. Some of it's workflows merit their own documentation.
| |
|
| |
|
| = Documentation = | | = Documentation = |
Line 7: |
Line 6: |
| {| class="wikitable" | | {| class="wikitable" |
| |- | | |- |
| | RESTAPI-v3 docs || https://developer.github.com/v3/ | | | official docs || https://docs.github.com/en |
| | |- |
| | | home || https://github.com/ |
| |- | | |- |
| |} | | |} |
| </blockquote><!-- Documentation --> | | </blockquote><!-- Documentation --> |
|
| |
|
| = API = | | = Notes = |
| <blockquote> | | <blockquote> |
| See [[github api]].
| | {| |
| </blockquote><!-- API -->
| | |- |
| | | | [[github api]] |
| = PR/Issue Filters =
| | |- |
| <blockquote>
| | | [[github ui]] |
| | | |- |
| <source lang="bash">
| | | [[github git]] |
| # shopify
| | |- |
| is:open is:pr -is:draft -reviewed-by:@me review-requested:@me
| | | [[github actions]] |
| </source>
| |
| | |
| <source lang="bash">
| |
| +is:pr # only include pull requests
| |
| -is:draft # remove drafts
| |
| -is:approved # removes approved (not if 1/2 approvals)
| |
| -reviewed-by:willjp # removes approved by me
| |
| created:2020-03-01..2020-05-01 # created within range
| |
| created:<2020-03-01 # created before date
| |
| </source>
| |
| </blockquote><!-- PR/issue filters -->
| |
| | |
| = Common Tasks =
| |
| <blockquote>
| |
| == Forking/Pull Request ==
| |
| <blockquote>
| |
| | |
| </blockquote><!-- forking/pull request -->
| |
| | |
| | |
| == Github push/pull with SSH key ==
| |
| <blockquote>
| |
| You'll need to change the github URL you are using.
| |
| | |
| <syntaxhighlight lang="bash">
| |
| git clone https://github.com/<Username>/<Project> # !!bad!!
| |
| | |
| git clone git@github.com:<Username>/<Project> # good
| |
| git clone github.com:<username>/<project> # also good (must specify user in ~/.ssh/config)
| |
| </syntaxhighlight>
| |
| | |
| You can quickly test authentication
| |
| <source lang="bash">
| |
| ssh git@github.com -i ~/.ssh/github
| |
| </source>
| |
| </blockquote><!-- github push/pull with ssh key -->
| |
| | |
| == importing existing git repo ==
| |
| <blockquote>
| |
| | |
| See [[git httpserver|hosting a git http server]] to share with github.
| |
| | |
| You can then use that to import your project.
| |
| | |
| </blockquote><!-- importing an existing repo -->
| |
| | |
| == deploy keys ==
| |
| <blockquote>
| |
| you can generate keys to provide read-only, or read-write access to a repo.
| |
| | |
| <source lang="bash">
| |
| ssh-keygen -t ed25519 # a strong key
| |
| </source>
| |
| | |
| <source lang="yaml">
| |
| https://github.com/<you>/<repo>/settings/keys/new # url to add new deploykey
| |
| </source>
| |
| | |
| next we'll create entries within our ssh config for the repo.
| |
| | |
| Create an `alias` for github.com, that will identify which deploykey you'll
| |
| be using here.
| |
| <source lang="ini">
| |
| Host <alias-for-your-repo> github.com
| |
| HostName github.com
| |
| IdentityFile /home/you/.ssh/deploykey
| |
| User git
| |
| </source>
| |
| | |
| | |
| Finally, clone the git repository using your alias instead of github.com.
| |
| <source lang="bash">
| |
| git clone <alias-for-your-repo>:<you>/<repo>
| |
| </source>
| |
| | |
| {{ NOTE |
| |
| Your alias must be a word, not a full address. Some examples:
| |
| | |
| * git will not recognize <code>myrepo:/you/myrepo</code> as an alias
| |
| * your alias cannot resolve to your repo ex: <code>git clone {alias}</code> is not sufficient. You will need to use <code>git clone {alias}:you/repo</code>.
| |
| }}
| |
| </blockquote><!-- deploy keys -->
| |
| | |
| == download single file ==
| |
| <blockquote>
| |
| <source lang="bash">
| |
| curl -O wget https://raw.githubusercontent.com/user/project/branch/filename
| |
| </source>
| |
| </blockquote><!-- download single file -->
| |
| </blockquote><!-- common tasks -->
| |
| | |
| = Github Actions =
| |
| <blockquote>
| |
| {| class="wikitable"
| |
| |- | | |- |
| | expression syntax || https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions | | | [[github markdown]] |
| |- | | |- |
| |} | | |} |
| </blockquote><!-- github actions --> | | </blockquote><!-- Notes --> |
| | |
| = PR magic =
| |
| <blockquote>
| |
| == fixes/closes ==
| |
| https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
| |
| | |
| | |
| </blockquote><!-- PR magic -->
| |
|
| |
|
| = Firewall = | | = Tools = |
| <blockquote> | | <blockquote> |
| == Getting github.com ip-address ==
| |
| github uses an unconventional setup for it's ip-addresses. Simply using a hostname resolves to just one of their
| |
| possible servers. If you are creating firewall rules, you'll need to create them for each address range. Here is
| |
| some code I've used to do this successfully in the past.
| |
|
| |
| {{ expand
| |
| | python script to get github address ranges
| |
| |
| |
| <source lang="python">
| |
| import sys
| |
| import json
| |
| import os
| |
|
| |
| if sys.version_info[0] < 3:
| |
| from urllib2 import urlopen
| |
| else:
| |
| from urllib.request import urlopen
| |
|
| |
|
| |
| def get_github_urls():
| |
| """
| |
| Returns:
| |
| list: ``[ '1.2.3.4/24', ... ]``
| |
| """
| |
| url = 'https://api.github.com/meta'
| |
| reply = urlopen(url)
| |
|
| |
| if sys.version_info[0] < 3:
| |
| status = reply.code
| |
| else:
| |
| status = reply.status
| |
| if status != 200:
| |
| raise RuntimeError('Unexpected reply: {}'.format(repr(reply)))
| |
|
| |
| # decode
| |
| rawdata = reply.read().decode('utf-8')
| |
| data = json.loads(rawdata)
| |
|
| |
| return data['git']
| |
| </source>
| |
| }}
| |
|
| |
| See
| |
| {| | | {| |
| | stackoverflow question || https://superuser.com/questions/704230/what-ports-to-open-up-for-github-to-install-and-work
| |
| |- | | |- |
| | official docs on githug ip-addrs || https://help.github.com/en/articles/about-githubs-ip-addresses | | | [[git]] |
| |}
| | |- |
| </blockquote><!-- firewall -->
| | | [[gh]] |
| | | |- |
| | | | [[github-searcher-cli]] |
| = Tips/Tricks =
| |
| <blockquote>
| |
| | |
| == Find PR from commit ==
| |
| <source lang="bash">
| |
| git log --merges --ancestry-path --oneline 9c34e5f6af..master \ | |
| | grep 'pull request' \
| |
| | tail -n1 \
| |
| | awk '{print $5}' \
| |
| | cut -c2- \
| |
| | xargs gh pr view -w
| |
| </source>
| |
| | |
| <source lang="bash">
| |
| # alternatively:
| |
| git describe --all --contains <commit> # returns branch name
| |
| | |
| </source>
| |
| </blockquote><!-- tips/tricks -->
| |
| | |
| = 3rd Party Tools =
| |
| <blockquote>
| |
| {|
| |
| | [[gh]] || official commandline client for github
| |
| |- | | |- |
| | [[github-searcher-cli]] || search github from the commandline | | | [[gh-search-cli]] |
| |- | | |- |
| | [[gh-search-cli]] || search github from the commandline
| |
| |} | | |} |
| | | </blockquote><!-- Tools --> |
| </blockquote><!-- 3rd party tools --> | |