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 / list-business-account-members-and-their-orgs.graphql
Last active March 14, 2019 17:31
GraphQL Examples with GitHub business account
query getOrgsInBusiness($slug: String!) {
business(slug: $slug) {
... on Business {
name
resourcePath
avatarUrl
members(first: 100) {
edges {
organizations(first: 100) {
@jonico
jonico / query_github_audit_log.graphql
Created June 6, 2019 22:11
How to query GitHub's audit log with GraphQL
query {
organization(login: "se-saml") {
auditLog(first: 50) {
edges {
node {
... on RepositoryAuditEntryData {
repository {
name
}
}
@jonico
jonico / azure-pipelines.yml
Last active September 14, 2020 04:17
Build and push a docker image into GitHub Package registry and create a tag in GitHub using Azure Pipelines (AZP) yaml files (azure-pipelines.yaml)
resources:
- repo: self
trigger:
- master
steps:
- script: ./cleanup.sh
displayName: Clean Up
@jonico
jonico / docker-build-publish.yaml
Created August 19, 2019 07:22
Build docker image and push to GPR with GitHub Actions
name: Build and publish Jekyll Docker image for Octocat Generator
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: clean up, docker login && docker build && docker push
@jonico
jonico / delete-all-package-versions.sh
Last active May 5, 2021 00:26
Delete all package versions of a package of certain GitHub repository
#!/bin/bash
# Script that works to delete private packages stored on Github Packages
#
# Script is based on the work of Troy Fontaine (github.com/troyfontaine)
GITHUB_TOKEN=$GPR_PAT
REPO_OWNER=$1
REPO_NAME=$2
PACKAGE_NAME=$3
@jonico
jonico / github-collaborators.sh
Last active October 20, 2024 13:53 — forked from muhammaddadu/github-add-colaborator
List, add and remove multiple collaborators from multiple repositories
#!/bin/bash
function help {
echo "Add collaborators to one or more repositories on github"
echo ""
echo "Syntax: $0 -u user [-l] [-D] -r repo1,repo2 <collaborator id>"
echo ""
echo " -u OAuth token to access github"
echo " -l list collaborators"
echo " -r repositories, list as owner/repo[,owner/repo,...]"
@jonico
jonico / deps-with-licenses.graphql
Last active October 2, 2020 21:07
Retrieve dependency graph including licenses
{
repository(owner: "rails", name: "rails") {
nameWithOwner
description
dependencyGraphManifests(withDependencies: true) {
nodes {
filename
dependenciesCount
exceedsMaxSize
parseable
@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:
@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 / count-committers-on-ghes.sh
Last active February 14, 2025 12:55
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|