Skip to content

Commit

Permalink
Merge pull request #8 from actionshub/reuseable-workflows
Browse files Browse the repository at this point in the history
feat: Update to reusable workflows
  • Loading branch information
damacus authored Feb 13, 2023
2 parents 064278b + 1eeebc8 commit 407c657
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 75 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/build-container.yml

This file was deleted.

40 changes: 6 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
---
name: Publish container
'on':
release:
types: [published]
name: Build & Publish container
"on":
push:
branches: [main]

jobs:
push_to_registry:
name: Publish to GitHub Container Registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Get the tag version
id: get_tag
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Code checkout
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.get_tag.outputs.VERSION }}
ghcr.io/${{ github.repository }}:latest
publish:
uses: actionshub/reusable-workflows/.github/workflows/publish.yaml@cce19fb345836ccd29168d876a8a8eca454fb27a
8 changes: 8 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Build & Publish container
"on":
pull_request:

jobs:
pull_request:
uses: actionshub/reusable-workflows/.github/workflows/pull_request.yaml@cce19fb345836ccd29168d876a8a8eca454fb27a
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM ruby:3.1-alpine
FROM ruby:3.2.1-alpine3.17

LABEL "com.github.actions.name"="Publish Gem to Rubygems" \
"com.github.actions.icon"="edit-3" \
"com.github.actions.color"="red" \
"com.github.actions.description"="Build and publish your gem to Rubygems"
COPY --chmod=750 entrypoint.sh /
COPY Gemfile Gemfile.lock /

RUN apk add --no-cache git
RUN gem install bundler keycutter
COPY entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
RUN apk add --no-cache git \
&& bundle install

ENTRYPOINT ["/entrypoint.sh"]
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'keycutter', '= 1.0.2'
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
keycutter (1.0.2)

PLATFORMS
arm64-darwin-22

DEPENDENCIES
keycutter (= 1.0.2)

BUNDLED WITH
2.4.1
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# publish-gem-to-rubygems

A GitHub Action to publish a RubyGem to RubyGems.org

This Action has been heavily influenced by [Jstastny's Publish-Gem-to-Github Action](https://github.com/jstastny/publish-gem-to-github).

## Usage

See [RubyGems API Key scopes][key] on how to obtain an api key

```yaml
jobs:
release:
runs-on: ubuntu-latest
- name: Checkout
uses: actions/checkout@v2

- name: Build and publish to RubyGems
uses: actionshub/publish-gem-to-rubygems@main
with:
api_key: ${{ secrets.RUBY_GEMS_API_KEY }}
```
[key]: https://guides.rubygems.org/api-key-scopes/
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ author: 'Dan Webb'
description: 'Run publish Gems to Rubygems'
runs:
using: 'docker'
image: docker://ghcr.io/actionshub/publish-gem-to-rubygems:v0.0.1
image: docker://ghcr.io/actionshub/publish-gem-to-rubygems:v1.0.0
inputs:
api_key:
description: "A RubyGems API Token"
branding:
icon: 'edit-3'
color: 'red'
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/bash

RUBYGEMS_API_KEY=$1
RUBYGEMS_API_KEY=${1}

[ -z "${RUBYGEMS_API_KEY}" ] && { echo "Missing input.rubygems_api_key!"; exit 2; }

Expand Down

0 comments on commit 407c657

Please sign in to comment.