Skip to content

Commit 1921eed

Browse files
authored
run CI on a nightly schedule and notify on failure (#93)
1 parent 3fcce96 commit 1921eed

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
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: 22 additions & 2 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'
19+
- "3.0"
1420
- 3.1
1521
env:
1622
BUNDLE_GEMFILE: Gemfile
@@ -36,3 +42,17 @@ jobs:
3642
ruby-version: 3.1
3743
- name: Run static type checks
3844
run: bundle exec srb tc
45+
notify_on_failure:
46+
runs-on: ubuntu-latest
47+
needs: [rspec, static_type_check]
48+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
49+
env:
50+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
51+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
52+
steps:
53+
- uses: slackapi/[email protected]
54+
with:
55+
payload: |
56+
{
57+
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
58+
}

0 commit comments

Comments
 (0)