Skip to content

Commit

Permalink
Merge pull request #6 from fac/simplify-workflows
Browse files Browse the repository at this point in the history
Simplify the workflows
  • Loading branch information
dmorgan-fa authored Jul 10, 2024
2 parents 5b3cd80 + 688fa7d commit e1bc677
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint workflow files

on:
pull_request:
paths:
- '.github/workflows/*.yml'
- '.github/workflows/*.yaml'

permissions:
pull-requests: write
contents: read

jobs:
actionlint:
uses: fac/hermod/.github/workflows/actionlint.yml@master
secrets: inherit
16 changes: 9 additions & 7 deletions .github/workflows/release_gem.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Build and Release Gem
on:
# This event will only trigger a workflow run if the workflow file is on the default branch.
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: ["Tests"]
types:
- completed
push:
branches:
- main
paths:
- lib/aws_local_config_parser/version.rb

jobs:
release:
name: Release to RubyGems.org
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }}
permissions:
id-token: write
contents: write
Expand All @@ -23,6 +21,10 @@ jobs:
with:
bundler-cache: true

# Run tests and rubocop
- name: Run tests and rubocop
run: bundle exec rake

# Release
- name: Release to RubyGems.org
uses: rubygems/release-gem@v1
14 changes: 1 addition & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
name: Tests

on:
push:
branches:
- main
paths-ignore:
- .editorconfig
- .gitignore
- .vscode/**
- bin/**
- Brewfile
- lefthook.yml
- LICENSE
- README.md
pull_request:

jobs:
Expand All @@ -25,5 +13,5 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run the default task
- name: Run tests and rubocop
run: bundle exec rake
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
brew 'actionlint'
brew 'lefthook'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ config.all_sso_sessions
## Making a commit
[Lefthook](https://github.com/evilmartians/lefthook/) has [been configured](./lefthook.yml) with pre-commit checks to:
- run `rubocop` for any `ruby` files
- run `actionlint` for any GitHub workflow files

If for some reason it's necessary, it's possible to temporarily skip `lefthook` with: `LEFTHOOK=0 git commit`.

Expand Down
3 changes: 3 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
pre-commit:
parallel: true
commands:
actionlint:
glob: ".github/workflows/*.{yml,yaml}"
run: actionlint {staged_files}
ruby-lint:
glob: "*.rb"
run: bundle exec rubocop {staged_files}

0 comments on commit e1bc677

Please sign in to comment.