zero
zero

Reputation: 3084

github action to copy a file from one repo to another

my company has created a complex way to move files between environments and now we would like to move certain built JS files (transpiled and minified) from one github repo to another. Is this possible using github actions?

Upvotes: 11

Views: 14336

Answers (1)

jessehouwing
jessehouwing

Reputation: 114661

The simplest option is to clone the target repo, copy the files into the target repo, use the git commandline to stage the files and then commit them. Add the code below in a script step

run: |
    git clone https://.:${{ secrets.GITHUB_TOKEN }}@github.com/project target
    rm everything but the .git directory
    copy source\files target
    cd target
    git add .
    git diff-index --quiet HEAD || git commit -m "Automatic publish from github.com/project"
    git push target master

Upvotes: 14

Related Questions