1

I'm currently trying to run a script in a repo in the master branch. I want the output of that script (html file) to go into another branch called output-branch.

Is there a command that let's me do this?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Jason000
  • 179
  • 2
  • 5
  • 14

3 Answers3

0

Write just:

git checkout output-branch

in the script, before generate the html-file.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
0

Git's convenience commands are built around the usual single-user single-checkout workflow.

Its core commands are ... not so constrained. What you're asking for is easy.

outputid=$(myscript | git hash-object -w --stdin)
treeid=$(echo 100644 blob $outputid$'\t'script-output | git mktree)
branchnow=$(git rev-parse -q --verify output-branch)
git update-ref refs/heads/output-branch  $(
        git commit-tree ${branchnow:+-p $branchnow} -m 'script output' $treeid
)

The first line is "add the myscript output to the repo and save its id".

The second is "make a directory path to that added content and save that directory's id"

The third is "check whether there's already a history"

The fourth and rest notably use the :+ expansion modifier, check the variable and if there's anything in it expand to what I give here, so ${branchnow:+-p $branchnow} expands to nothing if there's no existing branch history, or -p $branchnow if there's already history. The commit-tree and update-ref do exactly what it looks like they do: return an id for a newly-created commit of the snapshot you just built, and (re-)hang the output-branch branch tip label on that commit.

jthill
  • 55,082
  • 5
  • 77
  • 137
-1

You can run the script by getting the content of it with curl -sfL command on the fly and then run it by the executor. First, you need the raw format of the file by finding the file on Github or whatever and then click the raw view button on the page.

See the following example for bash script:

bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap.sh)"
Mesut GUNES
  • 7,089
  • 2
  • 32
  • 49
  • This is colossally dangerous, asking OP to download and blindly run commands from a mutable download link ... that (currently) themselves download and execute yet further-indirect code. – jthill Jul 14 '20 at 05:07
  • @jthill this command not downloading the file it is getting the content of it and run it. What blindly means, if op doesn't know the script why he needs to run it. He is asking to run it and there is no way to get the script and understand the consequences to run it by scripting way if you don't apply some AI. – Mesut GUNES Jul 14 '20 at 05:47