DEV Community

Cover image for How to release built artifacts from one to another repo on GitHub?
Oyster Lee
Oyster Lee

Posted on • Originally published at oysterd3.Medium

How to release built artifacts from one to another repo on GitHub?

GitHub’s free version package storage is limited at 500MB for private repo, and Unlimited for public repo.

There is a way that you can remain your source code in a private repo, and only release your packages in a public repo. This is how gathertown did.

softprops/action-gh-release able to achieve that in two lines of code.

# workflow.yml
# a lot code at the top
# ...
release:
  steps:
    - name: Release
      uses: softprops/action-gh-release@v1
      with:
        repository: ${{ secrets.owner }}/${{ secrets.repo }}
        token: ${{ secrets.CUSTOM_TOKEN }}

Enter fullscreen mode Exit fullscreen mode

By default repository will be the current repo, and the token will be GITHUB_TOKEN

GitHub automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run.

When you enable GitHub Actions, GitHub installs a GitHub App on your repository. The GITHUB_TOKEN secret is a GitHub App installation access token. You can use the installation access token to authenticate on behalf of the GitHub App installed on your repository. The token's permissions are limited to the repository that contains your workflow.

However, GITHUB_TOKEN will not allow you to release the packages to another repo, you need to provide your personal token

How can I get Personal Token?

GitHub > Setting > Developer settings > Personal access tokens > repo scope
Enter fullscreen mode Exit fullscreen mode

or you can access it via the direct link
1_IM5JwEXCIGGwVoW_bEhgBg

Publishing to another repo only require repo scope. Remember to copy-paste it somewhere after you got the token because you will not able to retrieve it for a second time.

Now create secrets in your repo

https://github.com/[OWNER]/[REPO]/settings/secrets/actions
Enter fullscreen mode Exit fullscreen mode

You can put any name you like, but make sure to change token: ${{ secret.THE_NAME_YOU_PUT }} in the workflow script

Discussion (0)