Skip to content

Commit

Permalink
use branch specified in payload when CI job is triggered by upstream …
Browse files Browse the repository at this point in the history
…dispatch [skip ci]
  • Loading branch information
mojavelinux committed Jul 13, 2021
1 parent 60c6c78 commit c4872a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/upstream-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
- name: Install dependencies
run: |
bundle --jobs 3 --retry 3
# FIXME: should switch to branch specified in payload
bundle exec ruby scripts/switch-to-asciidoctor-head.rb
bundle exec ruby scripts/switch-to-asciidoctor-head.rb ${{ github.event.client_payload.branch }}
rm -f Gemfile.lock
bundle --jobs 3 --retry 3
- name: Run tests
Expand Down
3 changes: 2 additions & 1 deletion scripts/switch-to-asciidoctor-head.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require 'fileutils'

branch = ARGV[0] || 'master'
# NOTE it's necessary to hot patch the installed gem so that RubyGems can find it without Bundler
asciidoctor_spec = Gem::Specification.find_by_name 'asciidoctor'
FileUtils.rm_r asciidoctor_spec.gem_dir, secure: true if Dir.exist? asciidoctor_spec.gem_dir
Process.wait Process.spawn %(git clone --depth=1 https://github.com/asciidoctor/asciidoctor #{File.basename asciidoctor_spec.gem_dir}), chdir: asciidoctor_spec.gems_dir
Process.wait Process.spawn %(git clone -b #{branch} --depth=1 https://github.com/asciidoctor/asciidoctor #{File.basename asciidoctor_spec.gem_dir}), chdir: asciidoctor_spec.gems_dir

Dir.chdir asciidoctor_spec.gem_dir do
new_asciidoctor_spec_contents = File.readlines 'asciidoctor.gemspec', mode: 'r:UTF-8'
Expand Down

0 comments on commit c4872a6

Please sign in to comment.