Skip to content

Commit d06b379

Browse files
authored
Merge branch 'master' into patch-1
2 parents 0815388 + 4f7dbac commit d06b379

89 files changed

Lines changed: 2950 additions & 1058 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "master" ]
20+
schedule:
21+
- cron: '25 1 * * 4'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'go', 'javascript', 'python', 'ruby' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Use only 'java' to analyze code written in Java, Kotlin or both
38+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
39+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v3
44+
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v2
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
54+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55+
# queries: security-extended,security-and-quality
56+
57+
58+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59+
# If this step fails, then you should remove it and run the build manually (see below)
60+
- name: Autobuild
61+
uses: github/codeql-action/autobuild@v2
62+
63+
# ℹ️ Command-line programs to run using the OS shell.
64+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65+
66+
# If the Autobuild fails above, remove it and uncomment the following three lines.
67+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68+
69+
# - run: |
70+
# echo "Run, Build Application using script"
71+
# ./location_of_script_within_repo/buildscript.sh
72+
73+
- name: Perform CodeQL Analysis
74+
uses: github/codeql-action/analyze@v2
75+
with:
76+
category: "/language:${{matrix.language}}"

.github/workflows/combine-prs.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: 'Combine PRs'
2+
# Based on https://github.com/hrvey/combine-prs-workflow
3+
4+
# Controls when the action will run - in this case triggered manually
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
branchPrefix:
9+
description: 'Branch prefix to find combinable PRs based on'
10+
required: true
11+
default: 'dependabot'
12+
mustBeGreen:
13+
description: 'Only combine PRs that are green (status is success)'
14+
required: true
15+
default: true
16+
combineBranchName:
17+
description: 'Name of the branch to combine PRs into'
18+
required: true
19+
default: 'combine-prs-branch'
20+
ignoreLabel:
21+
description: 'Exclude PRs with this label'
22+
required: true
23+
default: 'nocombine'
24+
25+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
26+
jobs:
27+
# This workflow contains a single job called "combine-prs"
28+
combine-prs:
29+
# The type of runner that the job will run on
30+
runs-on: ubuntu-latest
31+
32+
permissions:
33+
contents: write
34+
pull-requests: write
35+
36+
# Steps represent a sequence of tasks that will be executed as part of the job
37+
steps:
38+
- uses: actions/github-script@v6
39+
id: create-combined-pr
40+
name: Create Combined PR
41+
with:
42+
github-token: ${{secrets.GITHUB_TOKEN}}
43+
script: |
44+
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
45+
owner: context.repo.owner,
46+
repo: context.repo.repo
47+
});
48+
let branchesAndPRStrings = [];
49+
let baseBranch = null;
50+
let baseBranchSHA = null;
51+
for (const pull of pulls) {
52+
const branch = pull['head']['ref'];
53+
console.log('Pull for branch: ' + branch);
54+
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
55+
console.log('Branch matched prefix: ' + branch);
56+
let statusOK = true;
57+
if(${{ github.event.inputs.mustBeGreen }}) {
58+
console.log('Checking green status: ' + branch);
59+
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
60+
repository(owner: $owner, name: $repo) {
61+
pullRequest(number:$pull_number) {
62+
commits(last: 1) {
63+
nodes {
64+
commit {
65+
statusCheckRollup {
66+
state
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}`
74+
const vars = {
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
pull_number: pull['number']
78+
};
79+
const result = await github.graphql(stateQuery, vars);
80+
const [{ commit }] = result.repository.pullRequest.commits.nodes;
81+
const state = commit.statusCheckRollup.state
82+
console.log('Validating status: ' + state);
83+
if(state != 'SUCCESS') {
84+
console.log('Discarding ' + branch + ' with status ' + state);
85+
statusOK = false;
86+
}
87+
}
88+
console.log('Checking labels: ' + branch);
89+
const labels = pull['labels'];
90+
for(const label of labels) {
91+
const labelName = label['name'];
92+
console.log('Checking label: ' + labelName);
93+
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
94+
console.log('Discarding ' + branch + ' with label ' + labelName);
95+
statusOK = false;
96+
}
97+
}
98+
if (statusOK) {
99+
console.log('Adding branch to array: ' + branch);
100+
const prString = '#' + pull['number'] + ' ' + pull['title'];
101+
branchesAndPRStrings.push({ branch, prString });
102+
baseBranch = pull['base']['ref'];
103+
baseBranchSHA = pull['base']['sha'];
104+
}
105+
}
106+
}
107+
if (branchesAndPRStrings.length == 0) {
108+
core.setFailed('No PRs/branches matched criteria');
109+
return;
110+
}
111+
try {
112+
await github.rest.git.createRef({
113+
owner: context.repo.owner,
114+
repo: context.repo.repo,
115+
ref: 'refs/heads/' + '${{ github.event.inputs.combineBranchName }}',
116+
sha: baseBranchSHA
117+
});
118+
} catch (error) {
119+
console.log(error);
120+
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
121+
return;
122+
}
123+
124+
let combinedPRs = [];
125+
let mergeFailedPRs = [];
126+
for(const { branch, prString } of branchesAndPRStrings) {
127+
try {
128+
await github.rest.repos.merge({
129+
owner: context.repo.owner,
130+
repo: context.repo.repo,
131+
base: '${{ github.event.inputs.combineBranchName }}',
132+
head: branch,
133+
});
134+
console.log('Merged branch ' + branch);
135+
combinedPRs.push(prString);
136+
} catch (error) {
137+
console.log('Failed to merge branch ' + branch);
138+
mergeFailedPRs.push(prString);
139+
}
140+
}
141+
142+
console.log('Creating combined PR');
143+
const combinedPRsString = combinedPRs.join('\n');
144+
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString;
145+
if(mergeFailedPRs.length > 0) {
146+
const mergeFailedPRsString = mergeFailedPRs.join('\n');
147+
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString
148+
}
149+
await github.rest.pulls.create({
150+
owner: context.repo.owner,
151+
repo: context.repo.repo,
152+
title: 'Combined PR',
153+
head: '${{ github.event.inputs.combineBranchName }}',
154+
base: baseBranch,
155+
body: body
156+
});

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ But here it is, broken down:
1111
* _api_: here's a bunch of sample code relating to the API. Subdirectories in this
1212
category are broken up by language. Do you have a language sample you'd like added?
1313
Make a pull request and we'll consider it.
14-
* _graphql_: here's a bunch of sample GraphQL queries that can be run against our [GitHub GraphQL API](https://developer.github.com/v4/).
15-
* _hooks_: want to find out how to write a consumer for [our web hooks](https://developer.github.com/webhooks/)? The examples in this subdirectory show you how. We are open for more contributions via pull requests.
16-
* _pre-receive-hooks_: this one contains [pre-receive-hooks](https://help.github.com/enterprise/admin/guides/developer-workflow/about-pre-receive-hooks/) that can block commits on GitHub Enterprise that do not fit your requirements. Do you have more great examples? Create a pull request and we will check it out.
14+
* _graphql_: here's a bunch of sample GraphQL queries that can be run against our [GitHub GraphQL API](https://docs.github.com/graphql).
15+
* _hooks_: want to find out how to write a consumer for [our web hooks](https://docs.github.com/webhooks-and-events/webhooks/about-webhooks)? The examples in this subdirectory show you how. We are open for more contributions via pull requests.
16+
* _pre-receive-hooks_: this one contains [pre-receive-hooks](https://docs.github.com/enterprise-server/admin/policies/enforcing-policy-with-pre-receive-hooks) that can block commits on GitHub Enterprise that do not fit your requirements. Do you have more great examples? Create a pull request and we will check it out.
1717
* _scripts_: want to analyze or clean-up your Git repository? The scripts in this subdirectory show you how. We are open for more contributions via pull requests.
18+
* _sql_: here are sql scripts for custom reporting for GitHub Enterprise Server. We are open for more contributions via pull requests.

api/bash/create-teams.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Replace the "xxxxx" with the required values
3+
# Author: @ppremk
4+
5+
# Script to create GitHub Teams in bulk on GitHub.com Organization
6+
# PAT Tokens needs to have the correct scope to be able to create teams in an organization
7+
# Teams are added as an Array. Teams are created as stand alone teams. Team relationship is not defined
8+
9+
# To run the script:
10+
#
11+
# - Update VARS section in script
12+
# - chmod +x script.sh
13+
# - ./script.sh
14+
15+
# VARS
16+
orgname="xxx"
17+
pattoken="xxxxxxx"
18+
teams=("team-name-1" "team-name-2")
19+
20+
echo "Bulk creating teams in:"
21+
echo $orgname
22+
23+
for i in "${teams[@]}"
24+
do
25+
curl --request POST \
26+
--url "https://api.github.com/orgs/$orgname/teams" \
27+
--header "accept: application/vnd.github.v3+json" \
28+
--header "authorization: Bearer ${pattoken}" \
29+
--header "content-type: application/json" \
30+
--data "{\"name\": \"$i\", \"privacy\": \"closed\" }" \
31+
-- fail
32+
33+
retVal=$?
34+
if [ $retVal -ne 0 ]; then
35+
echo "Team creation failed! Please verify validity of supplied configurations."
36+
exit 1
37+
fi
38+
done
39+
echo "Teams succesfully created!"
40+
41+
42+
43+

api/java/deployment/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<dependency>
7474
<groupId>junit</groupId>
7575
<artifactId>junit</artifactId>
76-
<version>4.11</version>
76+
<version>4.13.1</version>
7777
<scope>test</scope>
7878
</dependency>
7979
<dependency>
@@ -84,7 +84,7 @@
8484
<dependency>
8585
<groupId>com.google.code.gson</groupId>
8686
<artifactId>gson</artifactId>
87-
<version>2.3.1</version>
87+
<version>2.8.9</version>
8888
</dependency>
8989
<dependency>
9090
<groupId>org.kohsuke</groupId>

0 commit comments

Comments
 (0)