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.example
file to.env
and set the appropriate configuration values.
To copy a release, run:
npm start <release name>
For example:
npm start v1.0.0
This 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
GET
request 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 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: |
*.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 build
Run the tool:
node ./dist/index.js <release name>
For example:
node ./dist/index.js v1.0.0
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