Skip to content

Actions updates

Actions updates #4

Workflow file for this run

name: BM CI
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
# allow manual trigger
workflow_dispatch:
# limit to only one running workflow per PR
concurrency:
group: ci-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
runs-on: ubuntu-latest
name: Tests & Linting
permissions:
contents: write
# limit workflow to run only on main repo and not to consume other workflow run quota
# but allow manual trigger on forked repos
if: github.event_name == 'workflow_dispatch' || github.repository == 'boldtrail/component-framework'
env:
PR_NUMBER: ${{ github.event.number }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RAILS_ENV: ci
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: '0'
# Ruby Setup
- name: Setup Ruby and gem caching
uses: ruby/setup-ruby@v1
with:
# ruby-version: 3.1.6 # handled in .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install Bundler
run: gem install bundler
- name: Install Gems
run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
- name: Run Minitest Tests
run: bundle exec ruby -Ilib -Itest test/**/*_test.rb
- name: Create tag
if: >
success() &&
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
github.repository == 'boldtrail/component-framework'
run: |
TAG=v$(ruby -I lib -r component/framework/version -e 'puts Component::Framework::VERSION')
git fetch --tags --force
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists. Skipping."
echo "created=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git tag "$TAG"
git push origin "$TAG"
echo "created=true" >> "$GITHUB_OUTPUT"