Github: Difference between revisions

From wikinotes
Line 30: Line 30:
= Common Tasks =
= Common Tasks =
<blockquote>
<blockquote>
= 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
|-
|}
</blockquote><!-- github actions -->


= PR magic =
= PR magic =

Revision as of 15:34, 19 September 2021

Github is a website that provides free public hosting of opensource projects.
It also provides other features like documentation hosting, issue tracking etc.

Documentation

RESTAPI-v3 docs https://developer.github.com/v3/

Notes

github ui
github git
github actions
github api
github markdown

Common Tasks

PR magic

fixes/closes

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue


Firewall

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.

python script to get github address ranges

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']

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


Tips/Tricks

Find PR from commit

git log --merges --ancestry-path --oneline 9c34e5f6af..master \
    | grep 'pull request' \
    | tail -n1 \
    | awk '{print $5}' \
    | cut -c2- \
    | xargs gh pr view -w
# alternatively:
git describe --all --contains <commit>  # returns branch name

3rd Party Tools

gh official commandline client for github
github-searcher-cli search github from the commandline
gh-search-cli search github from the commandline