Skip to content

ci更新

ci更新 #5

Workflow file for this run

name: main
on:
push:
branches:
- "master"
tags:
- "*"
pull_request:
branches:
- "master"
types: [opened, synchronize]
permissions:
contents: read
packages: write
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Up
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Code format check by Spotless
run: ./gradlew spotlessCheck
- name: Build Gem
run: ./gradlew gem
- name: Set up JRuby
uses: ruby/setup-ruby@v1
with:
ruby-version: jruby
- name: Publish to GPR
if: startsWith( github.ref, 'refs/tags/' )
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ./pkg/*.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
- name: Publish to RubyGems
if: startsWith( github.ref, 'refs/tags/' )
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
# TODO: If it is possible to accept input in the middle of a step, then the OTP Token should be inputted instead of generated.
gem install rotp -v 6.2.0
OTP_TOKEN=$(echo ${OTP_SECRET} | ruby -rtime -rrotp -e "puts ROTP::TOTP.new(STDIN.read.chomp, issuer: 'rubygems.org').at(Time.now)")
gem push --otp="${OTP_TOKEN}" ./pkg/*.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
OTP_SECRET: "${{secrets.RUBYGEMS_OTP_SECRET}}"