Skip to content

Commit

Permalink
Merge pull request #9 from gynzy/SRE-303-pull-jsonnet-20231115213652
Browse files Browse the repository at this point in the history
chore: update jsonnet [SRE-303]
  • Loading branch information
fhp authored Nov 15, 2023
2 parents 6daba6a + 96d6ed7 commit 7b50ad0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/jsonnet/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
447a8f6c677d3c799678319ea08734ed4b41196f
4187fef119638c2f8453bf4fd3d6da5641e4ffee
6 changes: 4 additions & 2 deletions .github/jsonnet/base.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
permissions=null,
concurrency=null,
continueOnError=null,
env=null,
)::
{
[name]: {
'timeout-minutes': timeoutMinutes,
'runs-on': (if runsOn == null then ['self-hosted', 'runner-2'] else runsOn),
'runs-on': (if runsOn == null then 'arc-runner-2' else runsOn),
} +
(
if image == null then {} else
Expand All @@ -47,7 +48,8 @@
(if services != null then { services: services } else {}) +
(if permissions == null then {} else { permissions: permissions }) +
(if concurrency == null then {} else { concurrency: concurrency }) +
(if continueOnError == null then {} else { 'continue-on-error': continueOnError }),
(if continueOnError == null then {} else { 'continue-on-error': continueOnError }) +
(if env == null then {} else { env: env })
},

ghExternalJob(
Expand Down
26 changes: 19 additions & 7 deletions .github/jsonnet/databases.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
server: 'eu-w4-metrics-production',
region: 'europe-west4',
project: 'unicorn-985',
lifecycle: 'deprecated',
},
'gynzy-test': {
type: 'mysql',
Expand All @@ -45,12 +46,6 @@
region: 'europe-west4',
project: 'gynzy-1090',
},
'accounts-production': {
type: 'mysql',
server: 'eu-w4-accounts-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-licenses-v8': {
type: 'mysql',
server: 'eu-w4-licenses-v8',
Expand All @@ -75,7 +70,24 @@
region: 'europe-west4',
project: 'unicorn-985',
},

'eu-w4-accounts-v8': {
type: 'mysql',
server: 'eu-w4-accounts-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-metrics-v8': {
type: 'mysql',
server: 'eu-w4-metrics-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-groups-v8': {
type: 'mysql',
server: 'eu-w4-groups-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
},

copyDatabase(mysqlActionOptions)::
Expand Down
53 changes: 38 additions & 15 deletions .github/jsonnet/deployment.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,61 @@
),
],

masterMergeDeploymentEventHook(deployToTest=false, prodBranch=null, testBranch=null)::
/*
* Creates a production deployment event on pr-close if the following conditions are met:
* - the pr is merged
* - the pr is not merged by the virko user
* - the pr is merged into the default branch
* - the merge sha is the latest commit on the default branch.
* this prevents a deployment from beeing created in a specific edge case:
* - PR A is merged into PR B
* - PR B is merged into the default branch
* - now github closes both PRs and without this additional sanity check, both would create a deploy event
*
* params:
* deployToTest {boolean} - if true, a deployment event is also created for the test environment
* prodBranch {string|null} - the branch to deploy to production. defaults to the default branch of the repository. but can be set to a differring release branch
* testBranch {string|null} - the branch to deploy to test. defaults to the default branch of the repository. but can be set to a differring test branch
* extraDeployTargets {string[]} - deploy targets to create deployment events for. defaults to ['production']. these targets will triger based on the configured prodBranch
* runsOn {string|null} - the name of the runner to run this job on. defaults to null, which will later on means the default self hosted runner will be used
*/
masterMergeDeploymentEventHook(deployToTest=false, prodBranch=null, testBranch=null, deployTargets=['production'], runsOn=null)::
$.pipeline(
'create-merge-deployment',
[
$.ghJob(
'create-merge-deployment-prod',
useCredentials=false,
runsOn=runsOn,
permissions={ deployments: 'write', contents: 'read' },
ifClause="${{ github.actor != 'gynzy-virko' && github.event.pull_request.merged == true}}",
steps=$._assertMergeShaIsLatestCommit(branch=(if prodBranch != null then prodBranch else '${{ github.event.pull_request.base.repo.default_branch }}')) +
std.map(
function(deploymentTarget)
$.action(
'publish-deploy-' + deploymentTarget + '-event',
'chrnorm/deployment-action@v2',
ifClause='${{ github.event.pull_request.base.ref == ' + (if prodBranch != null then "'" + prodBranch + "'" else 'github.event.pull_request.base.repo.default_branch') + " && steps.assert-merge-sha-is-latest-commit.outputs.CREATE_DEPLOY_EVENT == 'true' }}",
with={
token: $.secret('VIRKO_GITHUB_TOKEN'),
environment: deploymentTarget,
'auto-merge': 'false',
ref: '${{ github.event.pull_request.head.sha }}',
description: 'Auto deploy ' + deploymentTarget + ' on PR merge. pr: ${{ github.event.number }} ref: ${{ github.event.pull_request.head.sha }}',
payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}", "base_ref": "${{ github.event.pull_request.base.sha }}", "head_ref": "${{ github.event.pull_request.head.sha }}" }',
}
),
deployTargets,
) +
[
$.action(
'publish-deploy-prod-event',
'chrnorm/deployment-action@v2',
ifClause='${{ github.event.pull_request.base.ref == ' + (if prodBranch != null then "'" + prodBranch + "'" else 'github.event.pull_request.base.repo.default_branch') + " && steps.assert-merge-sha-is-latest-commit.outputs.CREATE_DEPLOY_EVENT == 'true' }}",
with={
token: $.secret('VIRKO_GITHUB_TOKEN'),
environment: 'production',
'auto-merge': 'false',
ref: '${{ github.event.pull_request.head.sha }}',
description: 'Auto deploy production on PR merge. pr: ${{ github.event.number }} ref: ${{ github.event.pull_request.head.sha }}',
payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}", "base_ref": "${{ github.event.pull_request.base.sha }}", "head_ref": "${{ github.event.pull_request.head.sha }}" }',
}
),
$.sendSlackMessage(
message='Deploy to prod of pr: ${{ github.event.number }} with title: ${{ github.event.pull_request.title }} branch: ${{ github.head_ref }} started!',
ifClause='${{ github.event.pull_request.base.ref == ' + (if prodBranch != null then "'" + prodBranch + "'" else 'github.event.pull_request.base.repo.default_branch') + " && steps.assert-merge-sha-is-latest-commit.outputs.CREATE_DEPLOY_EVENT == 'true' }}",
),
],
),
] +
(if deployToTest == true then
(if deployToTest == true && std.member(deployTargets, 'test') == false then
[
$.ghJob(
'create-merge-deployment-test',
Expand Down
3 changes: 2 additions & 1 deletion .github/jsonnet/docker.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
env={},
build_args=null,
registry='eu.gcr.io',
project='unicorn-985',
)::
$.action(
'build-docker',
Expand All @@ -16,7 +17,7 @@
gcloud_service_key: $.secret('docker_gcr_io_base64'),
image_name: imageName,
image_tag: imageTag,
project_id: 'unicorn-985',
project_id: project,
registry: registry,
} +
(if build_args != null then { build_args: build_args } else {}) +
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gynzy/ember-redux",
"version": "6.0.3",
"version": "6.0.4",
"description": "ember-cli addon that provides simple redux bindings for ember.js",
"scripts": {
"build": "ember build",
Expand Down

0 comments on commit 7b50ad0

Please sign in to comment.