Skip to content

Instantly share code, notes, and snippets.

@joeywang
Last active March 19, 2023 17:40
Show Gist options
  • Select an option

  • Save joeywang/4a537aa6745d43cd19373c693b87f1da to your computer and use it in GitHub Desktop.

Select an option

Save joeywang/4a537aa6745d43cd19373c693b87f1da to your computer and use it in GitHub Desktop.
  1. access token
# Use a https link. It's important for the authentication part.
gem "your_gem", git: "https://github.com/<owner>/<repo>.git", branch: "your_branch"

1.1 Setup Token 1.2 put into env as BUNDLE_GITHUB__COM detail

name: your_job

jobs:
  your_job:
    runs-on: ubuntu-latest
    env:
      BUNDLE_GITHUB__COM: "x-access-token:${{ secrets.YOUR_SECRET_NAME }}"

deploy key

  1. generate deployment key with ssh-keygen -t rsa -b 4096
  2. create and paste the key to new deployment key
  3. add private key of 1 to repo trying to access private repo as Actions Secret
  4. use secret in Github Actions

single key

# .github/workflows/ci.yml
jobs:
  compile-and-test:
    ...
    steps:
    ...
    - name: Give GitHub Actions access to Michael-F-Bryan/my-secret-repo
      uses: webfactory/ssh-agent@v0.5.4
      with:
        ssh-private-key: ${{ secrets.SECRET_REPO_DEPLOY_KEY }}

multiple keys

# ... contents as before
            - uses: webfactory/ssh-agent@v0.7.0
              with:
                  ssh-private-key: |
                        ${{ secrets.FIRST_KEY }}
                        ${{ secrets.NEXT_KEY }}
                        ${{ secrets.ANOTHER_KEY }}

multile keys from here

https://github.com/marketplace/actions/webfactory-ssh-agent

Reference


  1. https://lerso.hashnode.dev/how-to-use-a-gem-in-a-private-github-repo-in-your-rails-application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment