Skip to content

Commit 76782e6

Browse files
authored
run CI on a nightly schedule and notify on failure (#85)
1 parent 4c47086 commit 76782e6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
11+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'schedule' }}
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Tag and Push Gem

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: "0 0 * * *"
410

511
jobs:
612
rspec:
@@ -10,7 +16,7 @@ jobs:
1016
ruby:
1117
# See comment comes from https://github.com/ruby/setup-ruby#matrix-of-ruby-versions
1218
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
13-
- '3.0.6'
19+
- "3.0.6"
1420
- 3.1
1521
- 3.2
1622
- 3.3
@@ -27,7 +33,7 @@ jobs:
2733
- name: Set up Ruby ${{ matrix.ruby }}
2834
uses: ruby/setup-ruby@v1
2935
with:
30-
bundler-cache: false
36+
bundler-cache: false
3137
ruby-version: ${{ matrix.ruby }}
3238
- name: Update bundler
3339
run: gem install bundler && bundle install
@@ -45,3 +51,17 @@ jobs:
4551
ruby-version: head
4652
- name: Run static type checks
4753
run: bundle exec srb tc
54+
notify_on_failure:
55+
runs-on: ubuntu-latest
56+
needs: [rspec, static_type_check]
57+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
58+
env:
59+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
60+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
61+
steps:
62+
- uses: slackapi/[email protected]
63+
with:
64+
payload: |
65+
{
66+
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
67+
}

0 commit comments

Comments
 (0)