Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 570
zero Avatar asked Dec 19 '19 10:12

zero


People also ask

How do I move files from one GitHub repo to another?

$ git commit -m "Move file to new directory" # Commits the tracked changes and prepares them to be pushed to a remote repository. # To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again. Push the changes in your local repository to GitHub.com.

How do I copy a file from GitHub?

To copy the contents of a file, navigate to the file and click the Copy raw contents button on the toolbar: This feature is available in most desktop web browsers. Learn more about working with files.

How do I copy a folder from one repo to another?

Merge the files into the new repository B. Step 2: Go to that directory. Step 3: Create a remote connection to repository A as a branch in repository B. Step 4: Pull files and history from this branch (containing only the directory you want to move) into repository B.


1 Answers

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
like image 74
jessehouwing Avatar answered Sep 21 '22 15:09

jessehouwing