Skip to content

Instantly share code, notes, and snippets.

View clarkritchie's full-sized avatar
🫡
I prefer dashes to underscores

Clark Ritchie clarkritchie

🫡
I prefer dashes to underscores
View GitHub Profile
#!/usr/bin/env bash
OWNER=clarkritchie
REPO=${1:-my-stuff}
WORKFLOW_NAME=${2} # this is the filename, e.g. my-foo-gha.yaml
if [ -z "$WORKFLOW_ID" ]; then
echo "Must specify a workflow name"
exit 1
fi
@clarkritchie
clarkritchie / 1pw.yaml
Created May 27, 2024 03:17
GHA to Read Notes from 1Password Note and Push to GitHub Secrets
name: Set GitHub Secrets
on:
workflow_dispatch:
inputs:
repo:
description: "Select the Git repository"
type: choice
required: true
options:
name: Lint Code
on:
push:
branches:
- main
jobs:
lint-code:
name: Lint code
#!/usr/bin/env python3
#
# Quick and dirty script to purge contents from a versioned S3 bucket
#
import boto3, sys
BUCKET = 'some-bucket'
@clarkritchie
clarkritchie / cloudflare-record.sh
Last active March 22, 2024 00:51
Quick and Dirty CloudFlare stuff
#!/usr/bin/env bash
#
# this script gets your the cloudflare record id for a given hostname, type and zoneid
#
# https://www.puppeteers.net/blog/importing-dns-records-from-cloudflare-to-terraform/
#
# Get your API key then:
# export AUTHKEY="xxx"
if [ $# -ne 4 ]; then
@clarkritchie
clarkritchie / s3.sh
Last active March 9, 2024 00:24
Quick and dirty script for managing S3 buckets
#!/usr/bin/env bash
# quick and dirty script to
# - list buckets matching
# - copy buckets matching
# - remove buckets matching
SEARCH=${1}
ACTION=${2:-"ls"}
if [ -z ${SEARCH} ]; then
@clarkritchie
clarkritchie / old-branches.py
Created February 15, 2024 19:31
Quick script to delete old branches
#!/usr/bin/env python3
import sys
import subprocess
from datetime import datetime, timezone
try:
date = sys.argv[1]
yyyy,mm,dd = date.split("-")
except Exception:
print(f"Missing data argument, usage {__file__} YYYY-MM-DD")
#!/usr/bin/env bash
#
# This is a simple script to create/delete a Git tag in the form vA.B.C-sha
#
# Usage:
#
# ./build.sh 0.0.7
# ./build.sh v0.0.7-54477d3 delete -- will delete this tag
#
# The "v" is automatically prepended and the current sha is appended when the tag is created.
#! /bin/bash
#
# quick and dirty -- for each row in CSV 1, see if that field exists in CSV 2
#
skip_headers=1
while IFS="," read -r c1 c2 c2 c4 c5 c6 c7 # 'email' is field c2
do
if ((skip_headers))
then
echo "skipping header row"
@clarkritchie
clarkritchie / example.yml
Created December 12, 2023 20:35
Python in GitHub Action
- name: Check release type
id: is-patch-release
# The -u means 'unbuffered', so print() statements in your python code are output correctly
# otherwise, they might be out of order with stdout from commands your code calls
# {0} is replaced with the name of the temporary file GitHub Actions creates with
# the contents of the run:
shell: python -u {0}
run: |
import os
import re