Skip to content

Commit

Permalink
Adding explicit permissions to release workflow
Browse files Browse the repository at this point in the history
# What
Adding the 'write' permissions so the release workflow can release the gem.

Also reducing the need to run `rake` (e.g. `tests`) twice.
  • Loading branch information
dmorgan-fa committed May 1, 2024
1 parent 45fc469 commit 82345ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
38 changes: 8 additions & 30 deletions .github/workflows/release_gem.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
# Build, test and push gems to the FreeAgent registry.
# https://github.com/orgs/fac/packages?ecosystem=rubygems
# https://www.notion.so/freeagent/Internal-gems-5c8098501fcc48e4921be31aa9b4d495
name: Build and Release Gem
on:
push:
branches:
- main
pull_request:
workflow_run:
workflows: ["Tests"]
types:
- completed
workflow_dispatch:

jobs:
tests:
runs-on: ubuntu-latest
name: Run tests

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1 # .ruby-version
with:
bundler-cache: true # bundle install

# Tests expect a user like git setup
- name: Setup Git
run: |
git config --global user.name "$(git log -1 --pretty=format:%an)"
git config --global user.email "$(git log -1 --pretty=format:%ae)"
- name: Test
run: bundle exec rake

# Builds that pass testing above, will trigger a build and push of the new
# gem version to the registry. If the version.rb has not been bumped since
# the last release, the push will no-op.
release:
needs: tests
name: Release to GitHub Packages
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
packages: write
contents: write

steps:
- uses: fac/ruby-gem-setup-credentials-action@v2
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/main.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Ruby
name: Tests

on:
push:
branches:
- main

pull_request:

jobs:
Expand Down

0 comments on commit 82345ee

Please sign in to comment.