Skip to content

Commit

Permalink
ci/cd: refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Apr 6, 2023
1 parent 6630bf2 commit 97fbece
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 4 deletions.
Empty file removed .github/actions/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions .github/actions/notify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Define notification message
description: Identify an appropriate notification message.
branding:
icon: 'message-square'
color: 'green'
outputs:
txt:
description: The message.
value: ${{ steps.message.outputs.txt }}
runs:
using: composite
steps:
- name: Define notification message
id: message
run: |
if [ -n "${{ github.event.head_commit.message }}" ]
then
echo txt="${{ github.event.head_commit.message }}" >> $GITHUB_OUTPUT
elif [ -n "${{ github.event.schedule }}" ]
then
echo txt="regular healthcheck" >> $GITHUB_OUTPUT
elif [ -n "${{ github.event.inputs.reason }}" ]
then
echo txt="${{ github.event.inputs.reason }}" >> $GITHUB_OUTPUT
fi
shell: bash
14 changes: 14 additions & 0 deletions .github/workflows/caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Cache invalidation

on:
workflow_dispatch:
inputs:
reason:
type: string
default: manual healthcheck
required: true

schedule:
- name: At 06:00 on Sunday, UTC
Expand Down Expand Up @@ -41,11 +46,20 @@ jobs:
if: failure() || success()

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '🧹 ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ name: Continuous integration

on:
workflow_dispatch:
inputs:
reason:
type: string
default: manual healthcheck
required: true

pull_request:
branches: [ main ]
paths:
- .github/workflows/ci.yml
- package*.json
- '.github/workflows/ci.yml'
- 'package*.json'
- '**.jsx?'
- '**.tsx?'

push:
branches: [ main ]
paths:
- .github/workflows/ci.yml
- package*.json
- '.github/workflows/ci.yml'
- 'package*.json'
- '**.jsx?'
- '**.tsx?'
tags: [ '!*' ]
Expand Down Expand Up @@ -66,11 +71,20 @@ jobs:
if: github.event_name != 'pull_request' && (failure() || success())

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '⚙️ ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
14 changes: 14 additions & 0 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Dependabot at weekends

on:
workflow_dispatch:
inputs:
reason:
type: string
default: manual healthcheck
required: true

schedule:
- name: At 06:00 on Saturday and Sunday, UTC
Expand Down Expand Up @@ -37,11 +42,20 @@ jobs:
if: failure() || success()

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '🤖 ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
14 changes: 14 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Documentation delivery

on:
workflow_dispatch:
inputs:
reason:
type: string
default: manual healthcheck
required: true

push:
branches: [ main ]
Expand Down Expand Up @@ -47,11 +52,20 @@ jobs:
if: failure() || success()

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '📚 ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
13 changes: 13 additions & 0 deletions .github/workflows/runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
description: Only log actions, do not perform any delete operations.
type: boolean
required: false
reason:
type: string
default: manual healthcheck
required: true

jobs:
delete:
Expand All @@ -45,11 +49,20 @@ jobs:
if: failure() || success()

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '🗑️ ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
30 changes: 30 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Issue invalidation

on:
workflow_dispatch:
inputs:
reason:
type: string
default: manual healthcheck
required: true

schedule:
- name: At 06:00 every day, UTC
Expand Down Expand Up @@ -46,3 +51,28 @@ jobs:
close-pr-message: >
This pull request was closed because it has been stalled for 7 days with no activity.
delete-branch: true

notify:
name: Notifying
needs: [ check ]
runs-on: ubuntu-latest
if: failure() || success()

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Define notification message
id: message
uses: ./.github/actions/notify

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_FOOTER: made with ❤️ for everyone, OctoLab
SLACK_ICON: https://github.com/github.png?size=64
SLACK_MESSAGE: ${{ steps.message.outputs.txt }}
SLACK_TITLE: '⚠️ ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

0 comments on commit 97fbece

Please sign in to comment.