Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the workflows #6

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
Loading