githubgithub-actions

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?


Solution

  • 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