octomation/go-service

View on GitHub
.github/workflows/warmup.caches.yml

Summary

Maintainability
Test Coverage
name: Workflow caches warmup

on:
  workflow_dispatch:
    inputs:
      reason:
        description: The reason for dispatching it manually.
        type: string
        default: manual healthcheck
        required: true

  workflow_run:
    workflows: [ Workflow caches cleanup ]
    types: [ completed ]

jobs:
  deps:
    name: Caching deps
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        go:
          - 1.x
          - 1.20.x
          - 1.21.x

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }
      - name: Set up Go environment
        uses: actions/setup-go@v5.0.0
        with:
          go-version: ${{ matrix.go }}
          check-latest: true

      - name: Install dependencies
        run: make env deps

  docs:
    name: Caching docs deps
    runs-on: ubuntu-latest

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }
      - name: Set up Node.js environment
        uses: actions/setup-node@v4.0.1
        with:
          node-version: 20
          cache: npm
          cache-dependency-path: docs/package-lock.json
          check-latest: true
      - name: Install dependencies
        run: ./Taskfile docs npm ci

  tools:
    name: Caching tools
    runs-on: ubuntu-latest

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }
      - name: Set up Go environment
        uses: actions/setup-go@v5.0.0
        with:
          go-version: 1.21.x
          cache-dependency-path: tools/go.sum
          check-latest: true

      - name: Install dependencies
        run: make env tools

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

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }

      - name: Send notification
        uses: ./.github/actions/notify
        with:
          emoji: ♻️
          channel: ${{ secrets.SLACK_WEBHOOK }}
          success: ${{ ! contains(needs.*.result, 'failure') }}