Skip to content

Instantly share code, notes, and snippets.

View jonico's full-sized avatar
🚀
@ home

Johannes Nicolai jonico

🚀
@ home
View GitHub Profile
@jonico
jonico / README.md
Last active September 14, 2023 15:13
How to create an RDS database that is suitable for PlanetScale's import feature

MySQL on RDS configured for import to PlanetScale example

This folder contains an example Terraform configuration that deploys a MySQL database - using RDS in an Amazon Web Services (AWS) account - that is properly configured for PlanetScale's DB import feature.

It will make sure that the RDS database has the binlog exposed, gtid-mode set to ON and is using ROW-based replication. All these are pre-requisites for imports to work without zero downtime.

If you are going to write a lot of data in your database in a very short amount of time, don't forget the only manual step after the Terraform setup.

@jonico
jonico / .env
Last active June 1, 2023 09:04
How to run PlanetScale alongside with an MySQL enabled app that does not have any other internet access
PLANETSCALE_DB=brandnewdb
PLANETSCALE_BRANCH=mybranch
PLANETSCALE_ORG=jonico
PLANETSCALE_SERVICE_TOKEN=pscale_tkn_loCzIH7NktDK-GWJ71eX97Qr5D3a9iEO_pgHCSHUtw
PLANETSCALE_SERVICE_TOKEN_NAME=69xrlIwgs4ms
@jonico
jonico / wait-for-ps-branch-readiness.sh
Created October 4, 2021 21:36
shell script that waits for a PlanetScale branch to be ready for use and increases retry times exponentially
#!/bin/sh
# shell script that waits for a PlanetScale branch to be ready for use and increases retry times exponentially
# usage: wait-for-ps-branch-readiness.sh <db name> <branch name> <max retries>
function wait_for_branch_readiness {
local retries=$1
local db=$2
local branch=$3
@jonico
jonico / migrate_from_azure_blob_to_s3.sh
Last active August 20, 2021 03:08
Co-pilot examples (only comments have been written by me)
# copy Azure bloc storage files to S3 buckets
#
# Usage:
# ./copy-azure-blob-storage-to-s3.sh <blob storage container> <s3 bucket>
#
# Example:
# ./copy-azure-blob-storage-to-s3.sh my-container s3://my-bucket
#
# Note:
# This script requires a working Azure CLI.
@jonico
jonico / sync-github-actions.sh
Created June 21, 2021 15:14
Use actions-sync to sync actions/ org and some custom actions
#!/usr/bin/bash
cd
mkdir -p /tmp/actions
git clone https://github.com/github/platform-samples.git
sdk install groovy
cd platform-samples/api/groovy/
groovy ListReposInOrg.groovy -t $GH_PUBLIC actions > ~/repo-list
cd
wget https://github.com/actions/actions-sync/releases/download/v202009231612/gh_202009231612_linux_amd64.tar.gz
@jonico
jonico / dind-github-actions-k8s-example.yaml
Last active April 29, 2021 15:45
Example of a GitHub Action runner pod managed by summerwind/actions-runner-controller that was successfully tested with container and services keywords in action workflow files
apiVersion: v1
items:
- apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2021-04-29T15:09:09Z"
labels:
pod-template-hash: 65f67dcb66
runner-deployment-name: actions-runner-deployment-epona
runner-template-hash: 6788f4694c
@jonico
jonico / search-for-pattern-in-all-repos.sh
Last active March 3, 2021 22:43
Search through all reachable commits in all branches and tags in all repos on GitHub Enterprise Server for a pattern (run it on a backup system)
# Replace the string "Hyrule" with your search pattern - only run on backup system - will take a LOOOONG time to run through
ghe-console -y <<'ENDSCRIPT'
Repository.find_each do |repository|
if repository.active && !repository.empty? then
host,path = GitHub::Routing.lookup_route(repository.nwo)
puts "Processing repo #{repository.nwo} ..."
refs=`git --git-dir=#{path} rev-list --branches --tags | sort | uniq`
refs.each_line do |ref|
if system("git --git-dir=#{path} grep 'Hyrule' #{ref}")
puts "Found pattern in ref #{ref} in repo #{repository.nwo}: "
@jonico
jonico / count-committers-on-ghes.sh
Last active July 10, 2025 19:59
Count all unique committers in the last 90 days on GitHub Enterprise Server
ghe-console -y <<'ENDSCRIPT'
ActiveRecord::Base.connected_to(role: :reading) do
puts "Version 0.2.0"
emails = Set.new
start_time = 90.days.ago.beginning_of_day
Repository.where(active: true).find_each do |repo|
Push
.where(repository: repo)
.where("created_at >= ?", start_time)
.find_each do |push|
@jonico
jonico / optional-job-based-on-presence-of-a-secret.yaml
Created June 29, 2020 17:05
GitHub Actions optional job based on the presence of a secret
name: Build and publish Docker image + Container Scanning
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
dockerimage: ${{ steps.dockerimage.outputs.dockerimage }}
enablecontainerscanning: ${{ steps.enablecontainerscanning.outputs.enablecontainerscanning }}
@jonico
jonico / dynamic-runner-selection.yaml
Last active July 8, 2024 13:30
Dynamic selection of GitHub Runners - as GitHub Action matrix builds currently do not allow dynamic values
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build: