Skip to content

Commit

Permalink
Legge til jobber for å lage scratch pools
Browse files Browse the repository at this point in the history
  • Loading branch information
torhakon committed Aug 28, 2024
1 parent 5e0838a commit 02aa61f
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ciCreatePlatformPool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Replenish platform pool"
on:
workflow_dispatch:
inputs:
gitRef:
description: "Commit Id from where the pools should be created"
required: false
default: "main"

# 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:
clearCiPlatformPool:
if: github.event.schedule == '15 2 * * *'
uses: navikt/crm-workflows-base/.github/workflows/ciDeletePool.yml@master
with:
poolTag: "ciPlatformPool"
deleteJobType: "allscratchorgs"
secrets:
CRM_PROD_SFDX_URL: ${{ secrets.SF_DEVHUB_URL}}

cleanupPlatformPool:
if: github.event.schedule == '15 2 * * *'
uses: navikt/crm-workflows-base/.github/workflows/ciDeletePool.yml@master
with:
poolTag: "platform"
deleteJobType: "unassigned"
secrets:
CRM_PROD_SFDX_URL: ${{ secrets.SF_DEVHUB_URL}}

createPool:
if: ${{ always() }}
needs: [clearCiPlatformPool, cleanupPlatformPool]
strategy:
matrix:
poolConfigPath:
[
"config/sf-ci-platform-pool-def.json",
"config/sf-platform-pool-def.json",
]
uses: navikt/crm-workflows-base/.github/workflows/ciCreateScratchPool.yml@dxAtScale
with:
gitRef: ${{ inputs.gitRef || 'main' }}
poolConfigPath: ${{ matrix.poolConfigPath }}
permissions:
contents: read
packages: read
secrets: inherit

deleteOrphans:
if: ${{ always() }}
needs: createPool
uses: navikt/crm-workflows-base/.github/workflows/ciDeletePool.yml@master
with:
deleteJobType: "orphans"
secrets:
CRM_PROD_SFDX_URL: ${{ secrets.CRM_PROD_SFDX_URL}}
18 changes: 18 additions & 0 deletions config/sf-ci-platform-pool-def.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/flxbl-io/json-schemas/main/scratchorg-pool-definition.schema.json",
"tag": "ciPlatform",
"maxAllocation": 1,
"expiry": 7,
"batchSize": 5,
"configFilePath": "config/project-scratch-def.json",
"relaxAllIPRanges": true,
"enableSourceTracking": false,
"retryOnFailure": true,
"succeedOnDeploymentErrors": true,
"installAll": true,
"fetchArtifacts": {
"npm": {
"scope": "navikt"
}
}
}
18 changes: 18 additions & 0 deletions config/sf-platform-pool-def.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/flxbl-io/json-schemas/main/scratchorg-pool-definition.schema.json",
"tag": "platform",
"maxAllocation": 2,
"expiry": 1,
"batchSize": 5,
"configFilePath": "config/project-scratch-def.json",
"relaxAllIPRanges": true,
"enableSourceTracking": true,
"retryOnFailure": true,
"succeedOnDeploymentErrors": true,
"installAll": true,
"fetchArtifacts": {
"npm": {
"scope": "navikt"
}
}
}

0 comments on commit 02aa61f

Please sign in to comment.