Copies a release (including its name, body and assets) from one GitHub owner/repository to another.
This tool uses the GitHub API to fetch the details and assets of a given release from a repository, then create a duplicate of it in a different owner/repository.
Release asset files are stored locally in the location specified by the TEMP_DIR environment variable.
- Node 20.x
- Install dependencies with
npm ci - Copy the
.env.examplefile to.envand set the appropriate configuration values.
To copy a release, run:
npm start <release name>For example:
npm start v1.0.0To copy all releases from oldest to newest (skipping any that already exist at the destination):
COPY_ALL_RELEASES=true npm startThis will:
- Call the GitHub search API using the query defined in
.env - For each search result, query GitHub's API for file metadata, such as the download URL
- Make a
GETrequest to the download URL and save the contents of the file to a directory namedspecs
This tool can be consumed as a GitHub Action, in your own GitHub Actions workflows.
For example:
steps:
- name: Copy specific release from one repo to another
uses: DeloitteDigitalUK/github-release-copier@HEAD
with:
release-name: "v1.0.0"
source-api-key: "${{ secrets.SOURCE_API_KEY }}"
source-owner: "octocat"
source-repo: "octorepo"
dest-api-key: "${{ secrets.DEST_API_KEY }}"
dest-owner: "anothercat"
dest-repo: "anotherrepo"
# optional
temp-dir: "./files"
body-replace-regex: "octocat"
body-replace-with: "octodog"
# include-assets uses regex patterns (one per line)
include-assets: |
.*\.example\.zip$
.*\.docs\.zip$The tool requires content read-only permissions for the repository it is querying and content read-write permissions for the repository in which it is creating the release.
Permissions for SOURCE_API_KEY:
- Metadata: Read-only
- Contents: Read-only
Permissions for DEST_API_KEY:
- Metadata: Read-only
- Contents: Read-write
This tool can be run locally using Docker or Node.js.
Build the tool:
npm ci
npm run buildRun the tool:
node ./dist/index.js <release name>For example:
node ./dist/index.js v1.0.0A shell script is provided that allows you to pass arguments via command line instead of environment variables:
# Set required API keys as environment variables
export SOURCE_API_KEY="ghp_source_token"
export DEST_API_KEY="ghp_dest_token"
# Copy a specific release
./copy-release.sh -S "owner1/repo1" -D "owner2/repo2" -t "./temp" v1.0.0
# Copy all releases
./copy-release.sh --all -S "owner1/repo1" -D "owner2/repo2" -t "./temp"Run ./copy-release.sh --help for full usage information.
Build the container:
docker build --tag DeloitteDigitalUK/github-release-copier .Run the tool:
docker run --rm -it \
--env-file .env \
DeloitteDigitalUK/github-release-copier <release name>For example:
docker run --rm -it \
--env-file .env \
DeloitteDigitalUK/github-release-copier v1.0.0