Skip to content

Instantly share code, notes, and snippets.

View malantin's full-sized avatar

Malte Lantin malantin

View GitHub Profile
@malantin
malantin / teams.graphql
Created February 27, 2023 20:38
Get all teams and their permissions on repositories via GraphQL
query
{
organization(login: "octodemo") {
teams(first: 100, after: null) {
nodes {
name
repositories {
nodes {
name
viewerPermission
@malantin
malantin / filtered-pr-checks.yml
Created January 18, 2023 11:35
How to filter required checks that run during a PR, which is useful for mono-repos.
name: "Pre-Merge Checks"
on:
workflow_dispatch:
pull_request:
branches: [ dev ]
# We only trigger long running tests on demand from another workflow
workflow_call:
inputs:
label_trigger:
@malantin
malantin / graphql
Last active September 20, 2022 15:51
Get users for repos in orgs
{
organization(login: "OrgName") {
repositories(first: 100, after: null) {
nodes {
id
nameWithOwner
description
url
collaborators(first: 20, after: null) {
edges {
admin@malantin-009c14c14d9d1b660-ghe-test-org:~$ ghe-console -y < ghas.rb
Loading production environment
Loading config/console.rb
Switch to inspect mode.
<ctiveRecord::Base.connected_to(role: :reading) do
GitHub[production] (main):002:1* puts "Version 1.2.2"
GitHub[production] (main):003:1> emails = Set.new
< start_time = 90.days.ago.beginning_of_day
<tory.where(active: true).find_in_batches do |batch|
< Configurable.try(:preload_configuration, batch)
ActiveRecord::Base.connected_to(role: :reading) do
puts "Version 1.2.2"
emails = Set.new
start_time = 90.days.ago.beginning_of_day
Repository.where(active: true).find_in_batches do |batch|
Configurable.try(:preload_configuration, batch)
batch.each do |repo|
Push
.where(repository: repo)
.where("created_at >= ?", start_time)
name: Remove old artifacts
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
age:
description: 'Age in days'
required: true
# Conntect to Azure AD
Connect-AzureAD
# Get the Enterprise Application for GitHub Enterprise with EMU
$githubEMUenterpriseApp = Get-AzureADServicePrincipal -Filter "Displayname eq 'GitHub Enterprise Managed User'"
# Get all groups you want to assign, based on their name
$groups = Get-AzureADGroup -all $true | Where-Object {$_.DisplayName -like "Dev*"} | Select displayname,objectid
# Loop through all groups and assign them to your Enterprise Application Role
# Approles[1] Billing Manager
# Approles[2] User
# Approles[3] Enterprise Owner
git remote add github https://github.com/{username}/example.git
git remote add ownserver https://ownserver/{username}/example.git
git remote set-url --add --push origin https://github.com/{username}/example.git
git remote set-url --add --push origin https://ownserver/{username}/example.git