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 @@
84ec8f29f0c97ca93ebcb74c1e338d3cb6c03302
4e950af19b855ed027f1d5b6df12bd3acfdd0a6c
6 changes: 0 additions & 6 deletions .github/jsonnet/databases.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ local images = import 'images.jsonnet';
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-responses-production': {
type: 'mysql',
server: 'eu-w4-responses-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'gynzy-test': {
type: 'mysql',
server: 'gynzy-test',
Expand Down
2 changes: 1 addition & 1 deletion .github/jsonnet/deployment.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ local notifications = import 'notifications.jsonnet';
if branch.notifyOnDeploy then
[
notifications.sendSlackMessage(
message='Deploy to ' + std.join(' and ', branch.deployments) + ' of <https://github.com/${{ github.action_repository }}/pulls/${{ github.event.number }}|*PR ${{ github.event.number }}*> started!\nTitle: ${{ github.event.pull_request.title }}\nBranch: ${{ github.head_ref }}',
message='Deploy to ' + std.join(' and ', branch.deployments) + ' of <https://github.com/${{ github.repository }}/pull/${{ github.event.number }}|*PR ${{ github.event.number }}*> started!\nTitle: ${{ github.event.pull_request.title }}\nBranch: ${{ github.head_ref }}',
ifClause=ifClause,
),
]
Expand Down
87 changes: 80 additions & 7 deletions .github/jsonnet/misc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,79 @@ local base = import 'base.jsonnet';
local images = import 'images.jsonnet';

{
checkout(ifClause=null, fullClone=false, ref=null)::
checkout(ifClause=null, fullClone=false, ref=null, preferSshClone=true)::
local with = (if fullClone then { 'fetch-depth': 0 } else {}) + (if ref != null then { ref: ref } else {});
local sshSteps = (if (preferSshClone) then
base.step(
'check for ssh/git binaries',
|||
if command -v git;
then
echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
echo "Git binary exists";
else
echo "Attempt to install git binary";
if command -v apk; then
echo "apk exists";
apk add git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
else
echo "No package manager found, unable to install git cli binary";
echo "gitBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;

if command -v ssh;
then
echo "sshBinaryExists=true" >> $GITHUB_OUTPUT;
echo "SSH binary exists";
exit 0;
else
echo "Attempt to install ssh binary";
if command -v apk; then
echo "apk exists";
apk add openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
else
echo "No package manager found, unable to install ssh cli binary";
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
|||,
id='check-binaries',
) else []);

// strip the ${{ }} from the IfClause so we can inject and add our own if clause
local localIfClause = (if ifClause == null then null else std.strReplace(std.strReplace(ifClause, '${{ ', ''), ' }}', ''));

if (preferSshClone) then
sshSteps +
base.action(
'Check out repository code via ssh',
'actions/checkout@v4',
with=with + (if preferSshClone then { 'ssh-key': '${{ secrets.VIRKO_GITHUB_SSH_KEY }}' } else {}),
ifClause='${{ ' + (if ifClause == null then '' else '( ' + localIfClause + ' ) && ') + " ( steps.check-binaries.outputs.sshBinaryExists == 'true' && steps.check-binaries.outputs.gitBinaryExists == 'true' ) }}",
) +
base.action(
'Check out repository code via https',
'actions/checkout@v4',
with=with,
ifClause='${{ ' + (if ifClause == null then '' else '( ' + localIfClause + ' ) && ') + " ( steps.check-binaries.outputs.sshBinaryExists == 'false' || steps.check-binaries.outputs.gitBinaryExists == 'false' ) }}",
) +
base.step('git safe directory', "command -v git && git config --global --add safe.directory '*' || true")
else
self.checkoutWithoutSshMagic(ifClause, fullClone, ref),

checkoutWithoutSshMagic(ifClause=null, fullClone=false, ref=null)::
local with = (if fullClone then { 'fetch-depth': 0 } else {}) + (if ref != null then { ref: ref } else {});
base.action(
'Check out repository code',
'actions/checkout@v3',
'actions/checkout@v4',
with=with,
ifClause=ifClause
) +
Expand Down Expand Up @@ -200,9 +268,14 @@ local images = import 'images.jsonnet';
function(app) std.flatMap(
function(env)
if std.isObject(app[env]) then
std.map(function(linkName) '[' + app.name + ' ' + env + ' ' + linkName + ' preview](' + app[env][linkName] + ')', std.objectFields(app[env]))
std.map(
function(linkName)
'[' + std.strReplace(std.strReplace(app.name + ' ' + env + ' ' + linkName, '(', ''), ')', '') + ' preview]' +
'(' + app[env][linkName] + ')',
std.objectFields(app[env])
)
else
['[' + app.name + ' ' + env + ' preview](' + app[env] + ')'],
['[' + std.strReplace(std.strReplace(app.name + ' ' + env, '(', ''), ')', '') + ' preview](' + app[env] + ')'],

app.linkToLinear,
),
Expand Down Expand Up @@ -374,12 +447,12 @@ local images = import 'images.jsonnet';
NODESELECTOR_TYPE: cluster.jobNodeSelectorType,
} + environment,
),

// Auto approve PRs made by specific users. Usefull for renovate PRs.
//
// Parameters:
// users: a list of users to auto approve PRs for. Defaults to gynzy-virko.
autoApprovePRs(users = ['gynzy-virko'])::
autoApprovePRs(users=['gynzy-virko'])::
base.pipeline(
'auto-approve-prs',
[
Expand All @@ -392,7 +465,7 @@ local images = import 'images.jsonnet';
),
],
useCredentials=false,
ifClause='${{ ' + std.join(' || ', std.map(function(user) 'github.actor == \'' + user + '\'', users)) + ' }}',
ifClause='${{ ' + std.join(' || ', std.map(function(user) "github.actor == '" + user + "'", users)) + ' }}',
),
],
permissions={
Expand Down
4 changes: 2 additions & 2 deletions .github/jsonnet/pnpm.jsonnet
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local base = import 'base.jsonnet';

{
install(args=[], with={})::
install(args=[], with={}, version='9.5.0')::
base.action(
'Install application code',
'pnpm/action-setup@v4',
with={
version: '9.5.0',
version: version,
run_install: |||
- args: %(args)s
||| % { args: args },
Expand Down
51 changes: 49 additions & 2 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,55 @@
"image": "eu.gcr.io/unicorn-985/docker-images_jsonnet:v1"
"runs-on": "ubuntu-latest"
"steps":
- "name": "Check out repository code"
"uses": "actions/checkout@v3"
- "id": "check-binaries"
"name": "check for ssh/git binaries"
"run": |
if command -v git;
then
echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
echo "Git binary exists";
else
echo "Attempt to install git binary";
if command -v apk; then
echo "apk exists";
apk add git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
else
echo "No package manager found, unable to install git cli binary";
echo "gitBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;

if command -v ssh;
then
echo "sshBinaryExists=true" >> $GITHUB_OUTPUT;
echo "SSH binary exists";
exit 0;
else
echo "Attempt to install ssh binary";
if command -v apk; then
echo "apk exists";
apk add openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
else
echo "No package manager found, unable to install ssh cli binary";
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'true' && steps.check-binaries.outputs.gitBinaryExists == 'true' ) }}"
"name": "Check out repository code via ssh"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.event.pull_request.head.sha }}"
"ssh-key": "${{ secrets.VIRKO_GITHUB_SSH_KEY }}"
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'false' || steps.check-binaries.outputs.gitBinaryExists == 'false' ) }}"
"name": "Check out repository code via https"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.event.pull_request.head.sha }}"
- "name": "git safe directory"
Expand Down
51 changes: 49 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,55 @@
"pull-requests": "read"
"runs-on": "ubuntu-latest"
"steps":
- "name": "Check out repository code"
"uses": "actions/checkout@v3"
- "id": "check-binaries"
"name": "check for ssh/git binaries"
"run": |
if command -v git;
then
echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
echo "Git binary exists";
else
echo "Attempt to install git binary";
if command -v apk; then
echo "apk exists";
apk add git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
else
echo "No package manager found, unable to install git cli binary";
echo "gitBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;

if command -v ssh;
then
echo "sshBinaryExists=true" >> $GITHUB_OUTPUT;
echo "SSH binary exists";
exit 0;
else
echo "Attempt to install ssh binary";
if command -v apk; then
echo "apk exists";
apk add openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
else
echo "No package manager found, unable to install ssh cli binary";
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'true' && steps.check-binaries.outputs.gitBinaryExists == 'true' ) }}"
"name": "Check out repository code via ssh"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.event.pull_request.head.sha }}"
"ssh-key": "${{ secrets.VIRKO_GITHUB_SSH_KEY }}"
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'false' || steps.check-binaries.outputs.gitBinaryExists == 'false' ) }}"
"name": "Check out repository code via https"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.event.pull_request.head.sha }}"
- "name": "git safe directory"
Expand Down
51 changes: 49 additions & 2 deletions .github/workflows/publish-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,55 @@
"pull-requests": "read"
"runs-on": "ubuntu-latest"
"steps":
- "name": "Check out repository code"
"uses": "actions/checkout@v3"
- "id": "check-binaries"
"name": "check for ssh/git binaries"
"run": |
if command -v git;
then
echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
echo "Git binary exists";
else
echo "Attempt to install git binary";
if command -v apk; then
echo "apk exists";
apk add git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y git && echo "gitBinaryExists=true" >> $GITHUB_OUTPUT;
else
echo "No package manager found, unable to install git cli binary";
echo "gitBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;

if command -v ssh;
then
echo "sshBinaryExists=true" >> $GITHUB_OUTPUT;
echo "SSH binary exists";
exit 0;
else
echo "Attempt to install ssh binary";
if command -v apk; then
echo "apk exists";
apk add openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
elif command -v apt; then
echo "apt exists";
apt update && apt install -y openssh-client && echo "sshBinaryExists=true" >> $GITHUB_OUTPUT && exit 0;
else
echo "No package manager found, unable to install ssh cli binary";
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
fi;
fi;
echo "sshBinaryExists=false" >> $GITHUB_OUTPUT;
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'true' && steps.check-binaries.outputs.gitBinaryExists == 'true' ) }}"
"name": "Check out repository code via ssh"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.sha }}"
"ssh-key": "${{ secrets.VIRKO_GITHUB_SSH_KEY }}"
- "if": "${{ ( steps.check-binaries.outputs.sshBinaryExists == 'false' || steps.check-binaries.outputs.gitBinaryExists == 'false' ) }}"
"name": "Check out repository code via https"
"uses": "actions/checkout@v4"
"with":
"ref": "${{ github.sha }}"
- "name": "git safe directory"
Expand Down
Loading