Skip to content

Commit

Permalink
Merge pull request #69 from ministryofjustice/NIT-1305-custom-scaling…
Browse files Browse the repository at this point in the history
…-times

Nit 1305 custom scaling times
  • Loading branch information
pbasumatary authored Jul 2, 2024
2 parents e36ecca + a19a1c9 commit f6a7c0e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/scale-up.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Scale Up Lower Environments

on:
schedule:
- cron: '0 6 * * 1-5'
workflow_call:
inputs:
environment:
description: 'Environment to scale up'
required: true
type: string

jobs:
scale-up:
runs-on: ubuntu-latest
strategy:
matrix:
environment: ["poc", "dev"]
environment:
name: ${{ matrix.environment }}
name: ${{ inputs.environment }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -35,7 +36,7 @@ jobs:
version: "v4.35.1"
force: true

- name: Scaling up Deployments in ${{ matrix.environment }} namespace
- name: Scaling up Deployments in ${{ inputs.environment }} namespace
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/schedule-scale-up.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Schedule Scale Up Environments

on:
schedule:
- cron: '0 6 * * 1-5' # Schedule for POC environment
- cron: '0 3 * * 1-5' # Schedule for DEV environment

jobs:
scale-up:
runs-on: ubuntu-latest
strategy:
matrix:
environment: ["poc", "dev"]
steps:
- name: Determine Environment
id: which-env
run: |
if [[ "0 6 * * 1-5" == "${{ github.event.schedule }}" && "${{ matrix.environment }}" == "poc" ]]; then
echo "ENV_TO_SCALE=poc" >> $GITHUB_ENV
elif [[ "0 3 * * 1-5" == "${{ github.event.schedule }}" && "${{ matrix.environment }}" == "dev" ]]; then
echo "ENV_TO_SCALE=dev" >> $GITHUB_ENV
else
echo "ENV_TO_SCALE=NONE" >> $GITHUB_ENV
- name: Call scale up workflow
if: env.ENV_TO_SCALE != 'NONE'
uses: ./.github/workflows/scale-up.yml
with:
environment: ${{ env.ENV_TO_SCALE }}

0 comments on commit f6a7c0e

Please sign in to comment.