Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/jsonnet/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3831fc029bded90b10ee04c78cd06cb6c498e26a
aa305cb073663f1cc427017459aa90fa37127e4a
16 changes: 16 additions & 0 deletions .github/jsonnet/actions.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* GitHub Action plugin references
*
* Centralised SHA-pinned references for external GitHub Actions used across workflows.
* Pinning to a SHA (rather than a tag) protects against supply-chain attacks where a
* tag is moved to point at a malicious commit. The trailing comment records the
* human-readable version that the SHA corresponds to at the time of pinning.
*/
{
checkout_action: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd', // v6
gcp_auth_action: 'google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093', // v3
gcp_setup_gcloud_action: 'google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db', // v3
pulumi_action: 'pulumi/actions@cd99a7f8865434dd3532b586a26f9ebea596894f', // v5
onepassword_load_secrets_action: '1password/load-secrets-action@92467eb28f72e8255933372f1e0707c567ce2259', // v4
slack_action: 'act10ns/slack@d96404edccc6d6467fc7f8134a420c851b1e9054', // v2
}
7 changes: 5 additions & 2 deletions .github/jsonnet/base.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ local misc = import 'misc.jsonnet';
* @param {object} [concurrency=null] - Job-level concurrency settings
* @param {boolean} [continueOnError=null] - Whether to continue workflow if job fails
* @param {object} [env=null] - Environment variables for all steps in the job
* @param {object} [strategy=null] - GitHub Actions matrix strategy (e.g., {matrix: {shard: [1,2,3]}, 'fail-fast': false})
* @returns {jobs} - GitHub Actions job definition
*/
ghJob(
Expand All @@ -58,6 +59,7 @@ local misc = import 'misc.jsonnet';
concurrency=null,
continueOnError=null,
env=null,
strategy=null,
)::
{
[name]: {
Expand All @@ -82,7 +84,8 @@ local misc = import 'misc.jsonnet';
(if permissions == null then {} else { permissions: permissions }) +
(if concurrency == null then {} else { concurrency: concurrency }) +
(if continueOnError == null then {} else { 'continue-on-error': continueOnError }) +
(if env == null then {} else { env: env }),
(if env == null then {} else { env: env }) +
(if strategy == null then {} else { strategy: strategy }),
},

/**
Expand Down Expand Up @@ -159,7 +162,7 @@ local misc = import 'misc.jsonnet';
* @docs https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idsteps
*
* @param {string} name - Display name for the step in the GitHub UI
* @param {string} uses - The action to use (e.g., 'actions/checkout@v4', './path/to/action')
* @param {string} uses - The action to use (e.g., 'actions/checkout@v6', './path/to/action')
* @param {object} [env=null] - Environment variables for this step
* @param {object} [with=null] - Input parameters to pass to the action
* @param {string} [id=null] - Unique identifier for this step (used to reference outputs)
Expand Down
12 changes: 8 additions & 4 deletions .github/jsonnet/cache.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,25 @@ local base = import 'base.jsonnet';
),

/**
* Removes a cache from the cache server.
*
* Removes a cache from the cache server and optionally removes local folders.
*
* This is a generic function that can be used to remove any cache. It is advised to wrap this function
* in a more specific function that removes a specific cache, setting the cacheName parameter.
*
* @param {string} cacheName - The name of the cache to remove. The name of the repository is usually a good option.
* @param {string} [version='v1'] - The version of the cache to remove.
* @param {array} [folders=[]] - Local folders to delete alongside the remote cache.
* @param {string} [ifClause=null] - An optional if clause to conditionally run this step.
* @returns {steps} - GitHub Actions step to remove cache from Google Cloud Storage
*/
removeCache(cacheName, version='v1')::
removeCache(cacheName, version='v1', folders=[], ifClause=null)::
base.step(
'remove ' + cacheName + ' cache',
run=
'set +e;\n' +
(if std.length(folders) > 0 then 'rm -rf ' + std.join(' ', folders) + '\n' else '') +
'gsutil rm "gs://files-gynzy-com-test/ci-cache/' + cacheName + '-' + version + '.tar.zst"\n' +
'echo "Cache removed"\n'
'echo "Cache removed"\n',
ifClause=ifClause,
),
}
9 changes: 9 additions & 0 deletions .github/jsonnet/clusters.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ local misc = import 'misc.jsonnet';
jobNodeSelectorKey: 'type',
jobNodeSelectorValue: 'worker',
},

'gh-runners': {
project: 'gh-runners',
name: 'gh-runners-2023',
zone: 'europe-west4',
secret: misc.secret('GCE_JSON'),
jobNodeSelectorKey: 'optio',
jobNodeSelectorValue: 'true',
},
}
4 changes: 2 additions & 2 deletions .github/jsonnet/deployment.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ local notifications = import 'notifications.jsonnet';
function(deploymentTarget)
base.action(
'publish-deploy-' + deploymentTarget + '-event',
'chrnorm/deployment-action@v2',
'chrnorm/deployment-action@500aa6a23c81ffa1acf71072aee3cfa2cc2e556a', // v2
ifClause=ifClause,
with={
token: misc.secret('VIRKO_GITHUB_TOKEN'),
Expand Down Expand Up @@ -173,7 +173,7 @@ local notifications = import 'notifications.jsonnet';
updateDeploymentStatus(status='${{ job.status }}')::
base.action(
'Update deployment status',
'chrnorm/deployment-status@v2',
'chrnorm/deployment-status@6df8d036fd2fee9eb82936733953da1f8382b41e', // v2
with={
state: status,
['deployment-id']: '${{ github.event.deployment.id }}',
Expand Down
18 changes: 18 additions & 0 deletions .github/jsonnet/helm.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=false] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job for production deployment
*/
helmDeployProdJob(
Expand All @@ -145,9 +146,11 @@ local services = import 'services.jsonnet';
fetchDependencies=false,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'deploy-prod',
runsOn=runsOn,
ifClause="${{ github.event.deployment.environment == '" + environment + "' }}",
image=image,
useCredentials=useCredentials,
Expand Down Expand Up @@ -213,6 +216,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=false] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job for test deployment
*/
helmDeployTestJob(
Expand All @@ -225,9 +229,11 @@ local services = import 'services.jsonnet';
fetchDependencies=false,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'deploy-test',
runsOn=runsOn,
ifClause="${{ github.event.deployment.environment == 'test' }}",
image=image,
useCredentials=useCredentials,
Expand Down Expand Up @@ -296,6 +302,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=false] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job for PR deployment
*/
helmDeployPRJob(
Expand All @@ -308,9 +315,11 @@ local services = import 'services.jsonnet';
fetchDependencies=false,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'deploy-pr',
runsOn=runsOn,
image=image,
useCredentials=useCredentials,
steps=[
Expand Down Expand Up @@ -369,6 +378,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=fetchDependencies] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job for PR cleanup
*/
helmDeletePRJob(
Expand All @@ -380,9 +390,11 @@ local services = import 'services.jsonnet';
fetchDependencies=fetchDependencies,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'helm-delete-pr',
runsOn=runsOn,
image=images.default_job_image,
useCredentials=false,
steps=[
Expand Down Expand Up @@ -483,6 +495,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=false] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job for canary deployment
*/
helmDeployCanaryJob(
Expand All @@ -495,9 +508,11 @@ local services = import 'services.jsonnet';
fetchDependencies=false,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'deploy-canary',
runsOn=runsOn,
image=image,
useCredentials=useCredentials,
ifClause="${{ github.event.deployment.environment == 'canary' }}",
Expand Down Expand Up @@ -566,6 +581,7 @@ local services = import 'services.jsonnet';
* @param {boolean} [fetchDependencies=false] - Whether to fetch Helm dependencies
* @param {boolean} [wait=false] - Whether to wait for resources to be ready before marking the release as successful
* @param {string} [timeout=null] - Time to wait for resources (pods) to become ready (e.g., '5m')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @returns {jobs} - Complete GitHub Actions job to kill canary deployment
*/
helmKillCanaryJob(
Expand All @@ -576,9 +592,11 @@ local services = import 'services.jsonnet';
fetchDependencies=false,
wait=false,
timeout=null,
runsOn=null,
)::
base.ghJob(
'kill-canary',
runsOn=runsOn,
ifClause="${{ github.event.deployment.environment == 'kill-canary' || github.event.deployment.environment == 'production' }}",
image=images.default_job_image,
useCredentials=false,
Expand Down
2 changes: 1 addition & 1 deletion .github/jsonnet/images.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Images are primarily hosted on Google Cloud registries (GCR and Artifact Registry).
*/
{
jsonnet_bin_image: 'europe-docker.pkg.dev/unicorn-985/private-images/docker-images_jsonnet:v1',
jsonnet_bin_image: 'europe-docker.pkg.dev/unicorn-985/private-images/docker-images_jsonnet:v2',
helm_action_image: 'docker://europe-docker.pkg.dev/unicorn-985/public-images/helm-action:v4',
mysql_action_image: 'docker://europe-docker.pkg.dev/unicorn-985/public-images/docker-images_mysql-cloner-action:v2',
docker_action_image: 'docker://europe-docker.pkg.dev/unicorn-985/public-images/push-to-gcr-github-action:v1',
Expand Down
1 change: 1 addition & 0 deletions .github/jsonnet/index.jsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(import 'base.jsonnet') +
{ actions: import 'actions.jsonnet' } +
{ clusters: import 'clusters.jsonnet' } +
(import 'databases.jsonnet') +
(import 'docker.jsonnet') +
Expand Down
Loading
Loading