GitHub Actions - Copy files between repos

by
Jeremy Canfield |
Updated: February 01 2025
| GitHub Actions articles
Let's say you have a file in repo "a" that you want to copy to repo "b". Here is an example GitHub Action that could be used.
name: Copy File
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
push:
branches:
- main
jobs:
copy-file:
runs-on: ubuntu-latest
steps:
- name: Checkout the my_org/repo_a repo
uses: actions/checkout@v4
with:
repository: 'my_org/repo_a'
path: 'repo_a'
- name: Checkout the my_org/repo_b repo
uses: actions/checkout@v4
with:
repository: 'my_org/repo_b'
path: 'repo_b'
- name: copy foo.txt from repo_a to repo_b
run: cp repo_a/path/to/foo.txt repo_b/path/to/foo.txt
- name: git commands
run: |
cd repo_b;
git config user.name "John Doe";
git config user.email "john.doe@example.com";
git add path/to/foo.txt;
git commit -m "it's a wonderful day in the neighborhood" path/to/foo.txt;
git push origin HEAD;
Did you find this article helpful?
If so, consider buying me a coffee over at