How to create deployment links in a Github PR? - github

I've noticed Github allows linking to deployments:
I currently have Travis CI doing automatic builds on new PRs and deploying the artifacts to transfer.sh. How could I get such a link to View deployment to show up in my Github PR?

You need to add an environment_url field when POST'ing the deployment status.
Additionally, you need to use the application/vnd.github.ant-man-preview+json Content-Type header as it's still a developer preview feature.
More info:
It's mentioned in the API docs https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
https://developer.github.com/changes/2016-04-06-deployment-and-deployment-status-enhancements/#link-to-a-live-deployment

Related

Deploy changes from GitHub to Salesforce

How can I add a custom button on GitHub.com which I could click on in order to deploy changes from the Master branch to a related Salesforce.com DEV Org?
What have you tried? Have you seen https://developer.salesforce.com/blogs/2020/01/using-salesforce-dx-with-github-actions ?
You can steal sample actions from SF official repo at https://github.com/trailheadapps/lwc-recipes.
You'll need to provide the secret login URL to your target org, there are blog posts how to generate it and store in GitHub variable, for example https://tigerfacesystems.com/blog/sfdx-continuous-integration/ or https://github.com/sfdx-actions/setup-sfdx
Last but not least - to have action available for manual run (not just automated) read up about "workflow_dispatch"

Azure Devops GIthub webhooks

We had azure pipeline which use to work, but recently the PR trigger are not working.
Hence, I deleted webhooks from github repo. I created new service account and new pipeline with new service account. However, it does not seem to recreate webooks in github.
any thoughts?
Which model are you using, classic editor build or YAML build?
If you are using YAML build, we could select GitHub as source.
And we could specify the target branches when validating your pull requests. For example, to validate pull requests that target master and releases/*, you can use the following pr trigger.
pr:
- master
- releases/*
If you are using classic editor build. We could select the Pull request validation trigger and check the Enable pull request validation check box to enable builds on pull requests. Check the pic below.
We could refer to this doc for more details.

Deploy site to GitHub pages after an action has been ran [duplicate]

This question already has answers here:
How to force GitHub Pages build?
(11 answers)
Closed 2 years ago.
Situation
I am using GitHub Pages to display a simple landing page for my project with direct download links to artifacts generated by a GitHub Action. This information is pulled from the GitHub API via this syntax in the GitHub Pages index.md:
[Download Installer (Windows)]({{ site.github.releases[0].assets[1].browser_download_url }})
When I push to the master branch, I run an action that automatically releases new binaries as GitHub Releases. Unfortunately, the GitHub Pages page is being deployed at the same time, with the GitHub API still providing the previous release as the latest release.
GitHub Pages configuration
Deployment page:
Question(s)
How can I tell GitHub to only trigger a deployment of the GitHub Pages page after the release action has completed? Does an Action exist to trigger what GitHub seems to do automagically after each push? And is there a way to disable the automatic deployment so that the page only gets deployed after a (successful) release?
The only action keep getting to when googling is peaceiris/actions-gh-pages, but it seems to have been made to deploy web projects to GitHub Pages. Am I correct in thinking this, or is there a way to use this action to accomplish what I described?
I'm not sure about GitHub's automagic Pages deploy, but if you're somehow able to replicate that into a job of its own in your workflow file, you can use the needs attribute to make the deploy job depend on the release job completing. The 2 jobs must be defined in the same .yml workflow file.

Trigger Visual Studio Team Services build for a GitHub Pull Request

How do you get VSTS to build when a PR is created in GitHub? I've tried several triggers in the VSTS build like refs/pull/*/merge and refs/pull/*/head. I have a build working when a commit is made to the master branch, but I can't get a build to trigger when a PR is created.
I get the following when a PR is created.
Also, the webhook history shows that a message was successfully posted to VSTS, but the build never starts.
The official Microsoft VSTS GitHub Integration extension now supports this directly.
I think it's the trigger. Try what's described in this blog post.
There is not an easy way to enable this today for PRs. It is on the VSTS feature backlog that we want to address soon.
The way to make it work today would be to do something like: add a webhook to call your own custom service endpoint. Within your service endpoint, you could then call into VSTS to queue a build, and the build would need a step to post success/fail back to GitHub.
In your custom service endpoint, you would need to make sure the user is authorized as a contributor on the GitHub repo.
On the new VSTS UI you can find it in Build Edit -> Triggers:

How to trigger a Jenkins 2.0 Pipeline job from a GitHub pull request

It looks like the GitHubPullRequestBuilder is not compatible with Jenkins v2.0 pipeline jobs.
How do you configure a pipeline job to be triggered from a GitHub pull request event?
The documentation on this topic is sparse and I cannot find any examples of this. Or is it better to create a web-hook in GitHub to trigger the pipeline job on the PR event?
I had similar issue. Here’s what worked for me
Pre-req
Jenkins ver. 2+ (I was using Jenkins 2.60)
Github (or Githhub
enterprise) account
Your github and Jenkins must be able to talk to
each other.
On Github
create a github Personal Access Token (PAT) with relevant rights.
For your repo, create a webhook with
URL as YourJenkinsURL/github-webhook/
Choose ‘Let me select individual events’ and check ‘Pull Request’
Add a Jenkinsfile to the root folder of your repo. For testing purpose you could put content as a basic hello world like below
pipeline {
agent any
stages {
stage('Test') {
steps {
echo 'Hello World ...'
}
}
}
}
On Jenkins
Install GitHub Pull Request Builder plugin. (You also need “Github” plugin but that should normally be installed as part of Jenkins ver 2+)
Jenkins – Credentials
Add github Personal Access Token (PAT) as a ‘secret text’ credential.
Add github username-password as ‘username-password’ credential.
Manage Jenkins – Configure System
Github – Github Servers : This is part of the Github plugin. Add a github server. ‘API URL’ It will default to https://api.github.com. If you are using enterprise github, replace with enterprise github url followed by /api/v3. For credential select the PAT option. Test the connection. ‘Manage Hooks’ is checked.
GitHub Pull Request Builder : for ‘GitHub Server API URL’ use same url as specified in Github Server section. Leave ‘Shared Secret’ blank. For credentials use ‘username-password’ credential. Test credentials to ensure its working. In my settings, ‘Auto-manage webhooks’ was checked.
Pipeline Job
Create a new item using ‘Pipeline’ option. Note: This is the vanilla Pipeline job, not Multibranch Pipeline.
General Section: Check ‘Github Project’ – Project URL : Enter your github repo url
Build Triggers: Check ‘GitHub Pull Request Builder’
For ‘GitHub API credentials’ select option you set for GitHub pull request builder in ‘Manage Jenkins – Configure System’ screen
For admin list: add your username
Check Use github hooks for build triggering
Pipeline:
Select ‘Pipeline Script from SCM’. Note this assumes that the root folder of your repo will contain a ‘Jenkinsfile’
SCM: Select ‘Git’
Repositories – enter repo detail. For credentials use ‘username-password’ based credentials.
Click Advanced and add refspec as +refs/pull/*:refs/remotes/origin/pr/*
Branch – should be ${sha1}
Script Path: defaulted to Jenkinsfile, leave as is.
Lightweight Checkout - Uncheck this (https://github.com/jenkinsci/ghprb-plugin/issues/507)
That’s it. You are all set. Creating a PR on master branch of your repo should now trigger your Jenkins Pipeline job
Some observations
Redelivering the webhook payload of a PR from github does not trigger the pipeline but opening a new PR or even re-opening a closed PR on github, triggers the pipeline job
In Pipeline Job Configuration, if you choose “Pipeline Script” and paste your pipeline script in there, the job doesn't trigger !!!
The flow in a nutshell can go like this:
You create your pipeline as code and save it in a file called Jenkinsfile at the root dir of your project. That code should describe how your project will get built. See here for examples: https://jenkins.io/doc/pipeline/examples/
Then you should create a new "Multibranch Pipeline Project" item in your Jenkins. You should set this up so as to scan your repo of step 1.
Now whenever you get a new PR branch opened on your step 1 repo, the branch will be checked-out and will get built according to the Jenkinsfile instructions included with it. You can set up more conditions on what gets built and when if you want to.
Notes:
"Multibranch Pipeline Project" example documentation: https://jenkins.io/doc/book/pipeline-as-code/ (scroll down to Multibranch Pipeline Projects)
Keep in mind that getting the plugin to build a PR after commending on the PR does not work. There is a discussion analyzing this here: https://github.com/jenkinsci/gitlab-plugin/issues/298 There are workarounds (also described in that discussion) but they are quite messy to set up.
The most straightforward way to use Pipeline with GitHub pull requests is to put the script into your repository under the name Jenkinsfile and then install the GitHub Branch Source plugin. Documentation
Follow the Below Steps for Triggering Jenkins Job Automatically on Pull request generated on GitHub
Create a web hook on GitHub i.e. http:///generic-
webhook-trigger/invoke
Content Type :application/json
Select Pull Request as event Now github Configuration Part is done.
Jenkins Job Configuration
Download Generic Webhook Trigger in Jenkins
Git Hub Configuration On Jenkins
Git Hub Configuration
7.Select Generic Webhook Trigger on jenkins
8.Generic Webhook Trigger Configuration on Jenkinsand follow step 9
9.After doing step 7 Jenkins job will get trigger on PullRequest
10.Step 8 required to get information from Pull request Payload
11.Branch configuration inside Generic Webhook Trigger to get Branch details from Pull Request
Thanks