Workflow Structure
yaml
1name: Workflow Name
2
3on: [push, pull_request]
4
5env:
6 RAILS_ENV: test
7
8jobs:
9 job-name:
10 runs-on: ubuntu-latest
11
12 env:
13 DATABASE_URL: postgres://localhost/test
14
15 services:
16 postgres:
17 image: postgres:15
18 env:
19 POSTGRES_PASSWORD: postgres
20 ports:
21 - 5432:5432
22
23 steps:
24 - uses: actions/checkout@v4
25 - run: echo "Hello World"Using Actions
yaml
1steps:
2 # Use action with version
3 - uses: actions/checkout@v4
4
5 # With inputs
6 - uses: ruby/setup-ruby@v1
7 with:
8 ruby-version: '3.2'
9 bundler-cache: true
10
11 # Run command
12 - run: bundle exec rspec
13
14 # Multi-line command
15 - run: |
16 bundle install
17 bundle exec rails db:setup
18 bundle exec rspecJob Dependencies
yaml
1jobs:
2 test:
3 runs-on: ubuntu-latest
4 steps: [...]
5
6 deploy:
7 needs: test # Runs after test passes
8 runs-on: ubuntu-latest
9 steps: [...]Conditionals
yaml
1steps:
2 - run: echo "Only on main"
3 if: github.ref == 'refs/heads/main'