Open GantMan opened 6 years ago
The code comes from here:
Danger doesn't strictly check if it's a PR, but cares about these build vars - could there be alternatives?
Yeah, there's not going to be a PULL_REQUEST_NUMBER
if semaphore is simply treating it as a branch. I assume that's the crux of the problem.
same 🥇
Have any updated ? I also have this problem. Do you have workaround for this one ?
Here's your workaround https://semaphoreci.com/docs/how-to-fetch-pull-request-number-from-github.html
Edit: These docs are outdated, but it does work with changes
#!/bin/env ruby
# Necessary for Danger to work in Semaphore -_-' see:
# https://semaphoreci.com/docs/how-to-fetch-pull-request-number-from-github.html
require 'octokit'
c = Octokit::Client.new(access_token: ENV['DANGER_GITHUB_API_TOKEN'], auto_paginate: true)
prs = c.pull_requests(ENV['SEMAPHORE_GIT_REPO_SLUG'], state: 'open')
current_pr = prs.select { |pr| pr[:head][:ref] == ENV['SEMAPHORE_GIT_BRANCH'] }
pr_value = current_pr.first[:number].to_s unless current_pr.nil?
puts pr_value
- export SEMAPHORE_REPO_SLUG=$SEMAPHORE_GIT_REPO_SLUG
- export PULL_REQUEST_NUMBER=$(ruby bin/pull_request_number.rb)
- bundle exec danger
Not sure where the docs for this page are located, otherwise I would have just done a PR: http://danger.systems/js/guides/getting_started.html
The semaphore integration works, but there's a catch. Semaphore won't do a PR build unless it's a fork. So anyone who owns the repo, and simply does branch PRs, will see this message:
I wrote to Semaphore and they responded with the following:
I believe a caveat should be added to the docs (I personally moved danger-js to Travis for this reason). But then again, maybe danger JS should detect semaphore and be willing to skip the detection process?
I hope this helps ^