Does Github support username variable in Readme.md? - github

I have a repository which contains a badge from Travis-CI. This badge is included in the Readme.md with the following link, as suggested by Travis-CI documentation:
[![Build Status](https://travis-ci.org/nikicc/orange3-text.svg?branch=master)](https://travis-ci.org/nikicc/orange3-text)
However, now everyone that forks my repo will got the links to my Travis-CI badge, since it is hardcoded along with my username. I would like to achieve that all forks automatically have the links to theirs badges, not mine. Is it possible to somehow bypass this by using some variable for the username of the repository inside Readme.md files on Github? Is there any nice solution for this?

There is an alternative way to make it work:
Github: Can I see the number of downloads for a repo?
(https://github.com/andry81-devops/github-accum-stats)
It can be adopted the same way for an external service or site with data. All you need is to write a shell or any other script and call it from the github workflow action (.github/workflows/blabla.yml file).
The only thing can be a problem here is the GitHub workflow pipline call frequency, which might has a limit something about 1 call per 1 hour or 15 minutes (I didn't test it).
The idea is the same - store the status in a separate repository and does update it from a GitHub workflow action. Later you can use another action to rewrite the statistic repository below the head commit to cut off the history of changes if not need it.

Related

How to add a link to already opened pull request on github?

I am a noob to github's organziation settings and all. Don't know if we need these settings for the question Im about to ask.
So what I want to achieve is to show the already opened pull request's link on a subsequent push. In the past when working with bitbucket and gitlab with a development team, the link used to appear both on the initial push to create a pull request and also on subsequent commits push to PR. But in my current workflow it only appears on initial push to create the PR. (Note I haven't been setting up repositories in the past myself and just starting to explore this area so no idea if in the past lead engineer has been adding any settings or not)
This is what I see on initial push:
And this is on subsequent push. No link to already opened pull request
What am I missing? And is it even possible to do?
Any read or keywords to search for would be appreciated.
First a remark : when running git push, lines prefixed with remote: are actually generated by something on the remote ("something" = a script or a program or ...). If you want to see something more, check if there is some setting on Github's side to re-display the merge request number when you update a branch (I must confess I don't know if and how this can be done).
If you want to find what pull request is linked to a known branch, there is a specific search filter (in the web GUI) for that : head:branch_name
As an example :
Here is how you could get PR #1037 (linked to a branch named leaksan-100-part2) on git's repository :
is:pr head:leaksan-100-part2
If you want to get this from a script, you should probably use Github's API :
the doc to Pulls API mentions a base attribute :
base string query Filter pulls by base branch name. Example: gh-pages.

Show commits and description but hide code in repository [Github]

I've almost done my first big project in React+Typescript+Redux and started it on Firebase with users and some database conneted with logged users.
It was supposed to be my project to portfolio before looking for my first dev job, but it start to be very complex.
Now I have idea to use it in the future to make commercial app.
So the problem is I don't want to publish my code on github, but at the same time I want to publish all my commits and repository description on Github for recrutiers (and all my tasks from trello table). Is it possible to publish only commits and description from github repository?
No, this is not possible. If your repository is public, anyone can clone the entire repository. The only way to make your code inaccessible is to make the repository private, which means nobody can see it without having permssion.

Run a Jupyter Notebook through Github Actions

I have a repository on Github that contains a notebook I'd like to run automatically. I've looked at this action, which seems useful, but I'm not quite sure how my actions.yaml file should look, as I'm pretty new to Github actions.
Example 1 and Example 2 sections of this Github action's author is an example of what your Github action workflow file should look like.
Since you're the user of this Github action, your repository will contain your workflow file under your .github/workflows directory. Your workflow action file can be named anything, as long as it's sitting in this location; i.e it doesn't have to be named actions.yaml
For another example, you can review the workflow file at my repository, again under .github/workflows. This makes use of another action (and it's currently all commented out as I don't want to run it right now), but you will get the idea and it can help you generalize and understand what goes into a workflow file.

Exclude files from the new pull request (github)

Bitbucket has a feature to exclude files from the new pull request and I'm wondering if there is a similar feature in GitHub?
Scenario:
I have a Branch A that has changes in .travis.yml I pushed those
changes and create a PR I need to merge all changes in this branch
except the changes in .travis.yml file.
No, there is no such feature in GitHub (to the best of my knowledge confirmed by a quick google search).
The best alternative, excluding the proposed duplicate question for using a workaround, is to refer to this blog page, stating that:
Previously, if you wanted to use GitHub to remove files from a pull
request, you’d need to switch to the pull request branch and look for
the individual file to delete it. Now, if you have write permission,
you can click on the ‘trash’ icon for a file right in the pull
request’s “Files changed” view to make a commit and remove it.
I haven't tested this method, but I feel like it is somehow related to the rejected "alternative workaround".

How to check whether I have a fork of a given GitHub repo?

Let's say there is a repository foo/bar which I forked to me/custom-bar. How do I check programmatically (API call maybe?) given foo/bar that there exists a fork that I own from this upstream? Currently, GitHub has the repos/owner/id/forks API endpoint that returns upto 100 entries if you explicitly mention it. I don't see any parameters for creating a custom query for this particular problem. Counting in the rate-limiting and stuff, I don't think it's possible to know this using this API endpoint if I had say a fork of the linux project where over 20k+ forks exist. Is there any fast and efficient way to know this?
Note: I don't want to use authentication if at all possible.
New option (June 2022), directly on GitHub (instead of locally through API)
The repository fork button now displays existing forks
A dropdown has been added to the Fork button to help you quickly find your forks of a repository. This includes forks in your personal account and in organizations that you're a member of.
This feature was inspired by Refined GitHub – an impressive open source project maintained by #fregante.
The feature was requested of GitHub through the GitHub Stars program.
Read more about forking a repository in the GitHub documentation.
We appreciate feedback on this and other topics in GitHub's public feedback discussions.
As a workaround... you can always try to fork your own repo (POST /repos/:owner/:repo/forks).
As explained in "Is it possible to 'fork a fork' in Github?", that won't be generally possible (for a sigle non-organization account) to do if your own repo is itself a fork.
A solution here will be:
Check your repositories using GET /users/:username/repos
For each repo which fork property is true, GEt repository information using GET /repos/:owner/:repo
Check the parent object in json response (that contains parent folder of fork) and validate if full_name is your foo/bar repo