Skip to content

Commit

Permalink
Flytte schedule ut i egen workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
torhakon committed Aug 30, 2024
1 parent f5cd5ac commit db58617
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 20 deletions.
55 changes: 35 additions & 20 deletions .github/workflows/ciCreatePlatformPool.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
name: "Replenish platform pools"
env:
poolTag: ""
on:
workflow_dispatch:
workflow_call:
inputs:
gitRef:
description: "Commit Id from where the pools should be created"
required: false
default: "main"
ciPoolTag:
description: "Ci Pool Tag"
type: string
ciPoolConfigPath:
description: "Ci Pool Config Path"
required: true
type: string
devPoolConfigPath:
description: "Dev Pool Config Path"
required: true
type: string
clearPools:
description: "If checked, clear unused scratches in the pools"
required: true
default: false
type: boolean
secrets:
GITHUB_TOKEN:
required: true
default: "ciPlatform"
SF_DEVHUB_URL:
required: true

workflow_dispatch:
inputs:
gitRef:
description: "Commit Id from where the pools should be created"
required: false
default: "main"
ciPoolConfigPath:
description: "Ci Pool Config Path"
required: true
default: "config/sf-ci-platform-pool-def.json"
devPoolTag:
description: "Dev Pool Tag"
required: true
default: "platform"
devPoolConfigPath:
description: "Dev Pool Config Path"
required: true
default: "config/sf-platform-pool-def.json"

# Det er satt opp skedulering for når poolet oppdateres.
# Det er ikke behov for å kjøre denne jobber 24/7 og det er derfor satt opp noen skeduleringer (husk at tid er UTC)
# Det kjøres en jobb hver time 08:00-17:00 mandag til fredag, dette er fordelt på to jobber fordelt på vinter/sommertid
# Hver natt opprettes det scratcher sånn at man ikke risikerer å være tom dagen etter. Denne kjører alle dager sånn at man ikke er tom i helger dersom noe kritisk skulle oppstå
schedule:
- cron: "15 06-15 * 4-10 1-5" #Sommertid: At minute 15 past every hour from 6 through 15 on every day-of-week from Monday through Friday in every month from April through October.
- cron: "15 07-16 * 1-3,11,12 1-5" #Vintertid: At minute 15 past every hour from 7 through 16 on every day-of-week from Monday through Friday in every month from January through March, November, and December.
- cron: "15 2 * * *" # At 02:15.
clearPools:
description: "If checked, clear unused scratches in the pools"
required: true
default: "false"

jobs:
createPool:
Expand All @@ -42,11 +57,9 @@ jobs:
matrix:
include:
- poolType: "CI"
# poolTag: ${{ inputs.ciPoolTag }}
poolConfigPath: ${{ inputs.ciPoolConfigPath }}
deleteJobType: allscratchorgs
- poolType: "DEV"
# poolTag: ${{ inputs.devPoolTag }}
poolConfigPath: ${{ inputs.devPoolConfigPath }}
deleteJobType: unassigned
env:
Expand All @@ -55,14 +68,16 @@ jobs:
contents: read
packages: read
steps:
- run: echo "poolTag=$(jq --raw-output '.tag' ${{ matrix.poolType.poolConfigPath }})" >> $GITHUB_ENV
- run: echo "poolTag=$(jq --raw-output '.tag' ${{ matrix.poolConfigPath }})" >> $GITHUB_ENV

- name: Print Vaules
run: |
echo Pool Tag: ${{ env.poolTag }}
echo Pool Type: ${{ matrix.poolType }}
echo Pool Config Path: ${{ matrix.poolConfigPath }}
echo Pool Delete Job Type: ${{ matrix.deleteJobType }}
echo Pool Delete Job Type: ${{ matrix.deleteJobType }}
echo Clear unused scratch orgs: ${{ inputs.clearPools }}
- uses: actions/checkout@v4
with:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/ciCreatePlatformPoolScheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "SHEDULED Replenish platform pools"
on:
# Det er satt opp skedulering for når poolet oppdateres.
# Det er ikke behov for å kjøre denne jobber 24/7 og det er derfor satt opp noen skeduleringer (husk at tid er UTC)
# Det kjøres en jobb hver time 08:00-17:00 mandag til fredag, dette er fordelt på to jobber fordelt på vinter/sommertid
# Hver natt opprettes det scratcher sånn at man ikke risikerer å være tom dagen etter. Denne kjører alle dager sånn at man ikke er tom i helger dersom noe kritisk skulle oppstå
schedule:
- cron: "15 06-15 * 4-10 1-5" #Sommertid: At minute 15 past every hour from 6 through 15 on every day-of-week from Monday through Friday in every month from April through October.
- cron: "15 07-16 * 1-3,11,12 1-5" #Vintertid: At minute 15 past every hour from 7 through 16 on every day-of-week from Monday through Friday in every month from January through March, November, and December.
- cron: "15 2 * * *" # At 02:15.
jobs:
createPool:
uses: navikt/sf-platform/.github/workflows/ciCreatePlatformPool.yml@main
with:
gitRef: "main"
ciPoolConfigPath: "config/sf-ci-platform-pool-def.json"
devPoolConfigPath: "config/sf-platform-pool-def.json"
clearPool: ${{ github.event.schedule == '15 2 * * *' }}
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SF_DEVHUB_URL: ${{ secrets.SF_DEVHUB_URL }}

0 comments on commit db58617

Please sign in to comment.