Skip to content

Action to Copy a Gem into Github Packages

Notifications You must be signed in to change notification settings

alessio-signorini/copy-gem-to-github-packages

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy Gem to Github Packages Action

.github/workflows/test.yml

This action copies a Gem from any repository (even if they required authentication) into the Github Packages repository of your organization.

This can be useful to make availabe a private/protected gem (e.g., sidekiq-pro or sidekiq-ent) to the entire organization without having to include the credentials in the Gemfile, or to create and keep updated a private repository of known/verified gems.

Inputs

  • gem_name - The name of the gem to copy [required]
  • gem_repository - The URL of the repository (default https://rubygems.org)

Output

The gem will be copied in the packages of the organization's repository where this action is ran.

ENVs

Until Github sets the GITHUB_TOKEN automatically it is necessary to manually specify it in the configuration below as

  env:
     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Single Step

This is the minimum code necessary for a single step to copy the httparty gem from the standard RubyGems repository into Github packages associated to the current git repository in your organization.

uses: alessio-signorini/copy-gem-to-github-packages@v2
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
  gem_name: 'httparty'

Advanced usage

This action will run every day at midnight and will copy the sidekiq-pro and sidekiq-ent gems from Sidekiq's protected repository into your organization's package repository. The basic auth credentials used to access the private repository are saved as secrets.

name: 'Refresh Packages'

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
  push:
  schedule:
    - cron:  '0 0 * * *'    # Run every day at midnight

jobs:
  refresh:
    runs-on: ubuntu-latest
    name: Refresh Packages
    steps:
      - name: sidekiq-pro
        uses: alessio-signorini/copy-gem-to-github-packages@v2
        with:
          gem_name: 'sidekiq-pro'
          gem_repository: 'https://${{ secrets.SIDEKIQ_AUTH }}@enterprise.contribsys.com'
      - name: sidekiq-ent
        uses: alessio-signorini/copy-gem-to-github-packages@v2
        with:
          gem_name: 'sidekiq-ent'
          gem_repository: 'https://${{ secrets.SIDEKIQ_AUTH }}@enterprise.contribsys.com'