Skip to content

CD

CD #16

Workflow file for this run

name: CD
on:
# This ensures we only run CD after the CI workflow has completed on the main branch.
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
# We only want to run this if CI completes *sucessfully*, see more here:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
- name: Tag and Push Gem
id: tag-and-push-gem
# This action basically runs `bundle exec rake release` if there is not an existing tag in GitHub
# for the current version of the gem, found in the `gemspec`.
uses: discourse/publish-rubygems-action@ec5415e2cc3509a5cc8c4eef9499cf3fb05f8391
env:
# This is provided to GitHub Actions automatically – you do not need to add this secret.
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# These are used when the CD workflow pushes new tags to your repository.
# Using tags helps people using your gem easily see changes between versions.
# To get this value, try: `git config --get user.email`
GIT_EMAIL: [email protected]
# To get this value, try: `git config --get user.name`
GIT_NAME: Gary Passero
# Get this from rubygems.org and add it as a secret to your repository.
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
- name: Create GitHub Release
# This creates a new release at https://github.com/rubyatscale/alexevanczuk-example-gem/releases,
# which serves as an automatically generated changelog.
run: gh release create v${{steps.tag-and-push-gem.outputs.gem_version}} --generate-notes
# We only create a release if the previous step has published a new version.
if: ${{ steps.tag-and-push-gem.outputs.new_version == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}