concourse ci does not trigger on certain committed files - concourse

First, I do know that if I use [ci skip] in the commit message to GitHub it should not trigger based upon the commit message. However, I am only committing one file to GitHub. So instead of using this commit message, is there a way to exclude certain files? I have been researching on https://concourse-ci.org/ for this but have yet to find what I am looking for.

See ignore_paths in the Git resource docs:
https://github.com/concourse/git-resource#source-configuration

Related

Travis CI to modify same branch

I want to use travis-ci to run a script and commit the result back to the same branch on github. (The script generates a markdown table of contents, but could be anything really). Obviously this causes an issue as travis will then see a new commit and run again ad infinitum. I tried to use
if: sender != "Travis CI"
In my .travis.yml, but the docs are extremely vague about what exactly 'sender' is matching against, and I see no way to inspect the run time values travis is using.
I use this method: https://gist.github.com/willprice/e07efd73fb7f13f917ea
to commit back to github.
Is there a better way to achieve what I want? Or what is the correct way to make this work with travis?
There might cleaner ways of doing it but one way is to use the following.
According to this documentation, you can simply add a "tag" or specific string to your commit message in order to avoid Travis building it.
Simply add [ci skip] or [skip ci] to your commit message and Travis will ignore it.
Your function in push.sh will become the following:
commit_website_files() {
git checkout -b gh-pages
git add . *.html
git commit --message "[skip cp] Travis build: $TRAVIS_BUILD_NUMBER"
}
Also you could still push to another branch which wouldn't be watched by Travis.
Hope this helps.

github API code repository state after each commit

Is there any way to have the full source code repo after each commit?
I mean for example using
https://api.github.com/repos/highcharts/highcharts/commits
would give me a list of commits, but I want to realize what was the effect of that commit to whole repo (I want to check whether any code duplication is added to whole project or not using some automatic tools). Is that possible?
I want to see the code effect, so having repo even after merging each commit would be fine.
Simply implement a listener to a webhook (see "Creating a Webhook"). Set it up to ball your listener at each push event.
You can then do a pull when called by the webhook, and get a fresh updated copy of the repo locally.
For other repos you don't have any control or whose owner is in your team, that webhook approach is not possible.
You would need to implement a scheduled polling approach, through a regular cron job for instance.
That would possible multiple commits, so you need to wrap that pull with a git log as in here.
git checkout master
git fetch
refs=$(git log --format='%H' ..origin/master)
for ref in ${refs}; do
# do your analysis commit by commit
done
git merge origin/master

How to enforce commit message for github PR commits only?

I know there are multiple node packages out there to enforce commit message format but they all seem to be done pre-commit, locally for 'all' checkins. Is there a way to enforce a commit message format only for the merging of PR to master, and not all checkins?
If you're looking for a native github method to achieve this, then no. There's no way to make github itself check your commit message for some pattern.
Otherwise, what you want is a status check to fail if commits messages do not meet your standard with github configured to disallow PR merge while any check fails. The simples way I can think of is to enable Travis-ci integration for the project and use one of the npm modules you mentioned as the test code and you're done.
There's now a github app that allows this: https://github.com/zeke/semantic-pull-requests. If you want to ensure that all your PR titles are semantically correct (perhaps because you're squash merging) be sure to add the configuration file and specify titleOnly: true

Using GitHub API to determine if the last commit to master was a result of a merged pull request?

We use GitHub flow as branching strategy which means that anything in master is the result of a merged pull request. It's trivial to get the last commit by doing the following.
GET https://api.github.com/repos/:org/:repo/git/refs/heads/master
However it seems non-trivial to work out the pull request that caused this commit.
Is it possible to find out the pull request that created this commit via the API?
The PR should be one of the parents—the second one—of the commit in master, since that commit is the result of a merge of the PR.
You can find that parent with the GitHub commit API
GET /repos/:owner/:repo/git/commits/:sha
GitHub doesn't offer a way to get the branch from a commit, but you could list all the PR and cross-reference the SHA1 found above with said PRs.

Connect an issue with a commit after the commit

I did a git commit and pushed to github, but forgot to mention the issue number in the commit (I forgot to write something like ... closes #123).
If I had mentioned the issue number in the commit message, github would have connected the commit to the issue. Is there any way to do this after the commit, when it's too late for me to change the commit message?
EDIT: Assume that it's too late to amend the commit or otherwise alter the history. I am really asking about github functionality, not git.
In your issue on GitHub, just write a comment with the commit hash. For instance:
Fixed with commit 61d949320fc0bf1a8dba09b3845bddcd153b1a64
GitHub will recognize it as a SHA and link to the right commit page.
The Github help page "Can I delete a commit message?" explain how to alter:
a commit you just pushed
older commits message
But since it changes the history, you need to make anyone having already pulled from the GitHub repo aware of that change.
If rewriting the history isn't possible, you can make a new commit, with a commit message including:
the close issue
the SHA1 of the previous commit.
GitHub will automatically link that old commit in your new commit message: see for istance the reference to commit cdfd948 in this git commit.