Skip to content

Commit 82345ee

Browse files
committed
Adding explicit permissions to release workflow
# What Adding the 'write' permissions so the release workflow can release the gem. Also reducing the need to run `rake` (e.g. `tests`) twice.
1 parent 45fc469 commit 82345ee

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

.github/workflows/release_gem.yml

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
1-
# Build, test and push gems to the FreeAgent registry.
2-
# https://github.com/orgs/fac/packages?ecosystem=rubygems
3-
# https://www.notion.so/freeagent/Internal-gems-5c8098501fcc48e4921be31aa9b4d495
41
name: Build and Release Gem
52
on:
6-
push:
7-
branches:
8-
- main
9-
pull_request:
3+
workflow_run:
4+
workflows: ["Tests"]
5+
types:
6+
- completed
107
workflow_dispatch:
118

129
jobs:
13-
tests:
14-
runs-on: ubuntu-latest
15-
name: Run tests
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
- uses: ruby/setup-ruby@v1 # .ruby-version
20-
with:
21-
bundler-cache: true # bundle install
22-
23-
# Tests expect a user like git setup
24-
- name: Setup Git
25-
run: |
26-
git config --global user.name "$(git log -1 --pretty=format:%an)"
27-
git config --global user.email "$(git log -1 --pretty=format:%ae)"
28-
29-
- name: Test
30-
run: bundle exec rake
31-
32-
# Builds that pass testing above, will trigger a build and push of the new
33-
# gem version to the registry. If the version.rb has not been bumped since
34-
# the last release, the push will no-op.
3510
release:
36-
needs: tests
3711
name: Release to GitHub Packages
3812
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
permissions:
15+
packages: write
16+
contents: write
3917

4018
steps:
4119
- uses: fac/ruby-gem-setup-credentials-action@v2

.github/workflows/main.yml renamed to .github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
name: Ruby
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- main
7-
87
pull_request:
98

109
jobs:

0 commit comments

Comments
 (0)