Skip to content

Commit 781719f

Browse files
committed
⬆️ Bump files with dotnet-file sync
# devlooped/oss - Update combine prs default message devlooped/oss@74189b0 - Use bot account for sync commit author devlooped/oss@1d3a2f4 - Use BOT_ defaults consistently devlooped/oss@98919f7 - Ensure checkout before defaults devlooped/oss@721ee85 - Rework to pass secrets explicitly devlooped/oss@15e9486 - Ensure both author and committer match devlooped/oss@d94ddb1 - Update to public bot defaults action devlooped/oss@b9671b9 - Add fallback GITHUB_TOKEN to bot defaults devlooped/oss@5406d90 - Resolve includes after file sync devlooped/oss@8f45cf2 - By default don't validate includes devlooped/oss@aed791a - Ignore errors creating the PR devlooped/oss@b97b8f1 - Always pass in auth headers to GH API devlooped/oss@a922d03 - Use a lighter down arrow, docs tag devlooped/oss@4bd76ee - Bump to include action with fragment support devlooped/oss@c62cfb4 - Switch to new clean v1 devlooped/oss@e9b17b5 - Don't resolve includes for changelog changes devlooped/oss@7985d4e - Fix syntax for excluding one file devlooped/oss@5d05e54 - Since dependabot doesn't consume API requests, do it more frequently devlooped/oss@4f070a4 - Move format check for last devlooped/oss@7db501b - Make build matrix configurable per-repo devlooped/oss@391da5e - Rename matrix lookup job and steps devlooped/oss@cf8e339 - Use simple bash variable expansion devlooped/oss@acedd1d # devlooped/.github - Simplify workflow, skip for bot accounts devlooped/.github@e347e5c # devlooped/sponsors - Refresh sponsors devlooped/sponsors@61c6354
1 parent e9c3a44 commit 781719f

13 files changed

Lines changed: 296 additions & 224 deletions

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ updates:
66
- package-ecosystem: nuget
77
directory: /
88
schedule:
9-
interval: weekly
9+
interval: daily

.github/workflows/build.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,29 @@ defaults:
2323
shell: bash
2424

2525
jobs:
26-
dotnet-format:
26+
os-matrix:
2727
runs-on: ubuntu-latest
28+
outputs:
29+
matrix: ${{ steps.lookup.outputs.matrix }}
2830
steps:
2931
- name: 🤘 checkout
3032
uses: actions/checkout@v2
31-
with:
32-
submodules: recursive
33-
fetch-depth: 0
34-
35-
- name: ⚙ dotnet
36-
uses: actions/setup-dotnet@v1
37-
with:
38-
dotnet-version: '6.0.x'
39-
40-
- name: ✓ ensure format
41-
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget
33+
34+
- name: 🔎 lookup
35+
id: lookup
36+
shell: pwsh
37+
run: |
38+
$path = './.github/workflows/os-matrix.json'
39+
$os = if (test-path $path) { cat $path } else { '["ubuntu-latest"]' }
40+
echo "::set-output name=matrix::$os"
4241
4342
build:
43+
needs: os-matrix
4444
name: build-${{ matrix.os }}
45-
needs: dotnet-format
4645
runs-on: ${{ matrix.os }}
4746
strategy:
4847
matrix:
49-
os: [windows-latest, ubuntu-latest, macOS-latest]
48+
os: ${{ fromJSON(needs.os-matrix.outputs.matrix) }}
5049
steps:
5150
- name: 🤘 checkout
5251
uses: actions/checkout@v2
@@ -83,3 +82,21 @@ jobs:
8382
run: |
8483
dotnet tool install -g --version 4.0.18 sleet
8584
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"
85+
86+
dotnet-format:
87+
runs-on: ubuntu-latest
88+
needs: build
89+
steps:
90+
- name: 🤘 checkout
91+
uses: actions/checkout@v2
92+
with:
93+
submodules: recursive
94+
fetch-depth: 0
95+
96+
- name: ⚙ dotnet
97+
uses: actions/setup-dotnet@v1
98+
with:
99+
dotnet-version: '6.0.x'
100+
101+
- name: ✓ ensure format
102+
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget

.github/workflows/changelog.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
name: changelog
22
on:
3+
workflow_dispatch:
34
release:
45
types: [released]
5-
workflow_dispatch:
6-
7-
env:
8-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
96

107
jobs:
118
changelog:
129
runs-on: ubuntu-latest
1310
steps:
14-
- name: 🔍 GH_TOKEN
15-
if: env.GH_TOKEN == ''
16-
env:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18-
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
19-
11+
- name: 🤖 defaults
12+
uses: devlooped/actions-bot@v1
13+
with:
14+
name: ${{ secrets.BOT_NAME }}
15+
email: ${{ secrets.BOT_EMAIL }}
16+
gh_token: ${{ secrets.GH_TOKEN }}
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
2019
- name: 🤘 checkout
2120
uses: actions/checkout@v2
2221
with:
2322
fetch-depth: 0
2423
ref: main
2524
token: ${{ env.GH_TOKEN }}
26-
25+
2726
- name: ⚙ ruby
2827
uses: ruby/setup-ruby@v1
2928
with:
@@ -32,11 +31,9 @@ jobs:
3231
- name: ⚙ changelog
3332
run: |
3433
gem install github_changelog_generator
35-
github_changelog_generator --user ${GITHUB_REPOSITORY%/*} --project ${GITHUB_REPOSITORY##*/} --token ${{ secrets.GITHUB_TOKEN }} --o changelog.md --config-file .github/.github_changelog_generator
34+
github_changelog_generator --user ${GITHUB_REPOSITORY%/*} --project ${GITHUB_REPOSITORY##*/} --token $GH_TOKEN --o changelog.md --config-file .github/.github_changelog_generator
3635
3736
- name: 🚀 changelog
3837
run: |
39-
git config --local user.name github-actions
40-
git config --local user.email github-actions@github.com
4138
git add changelog.md
42-
(git commit -m "🖉 Update changelog with ${GITHUB_REF#refs/*/}" && git push) || echo "Done"
39+
(git commit -m "🖉 Update changelog with ${GITHUB_REF#refs/*/}" && git push) || echo "Done"

.github/workflows/combine-prs.yml

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

.github/workflows/dotnet-file.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@ on:
99

1010
env:
1111
DOTNET_NOLOGO: true
12-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
1312

1413
jobs:
1514
sync:
1615
runs-on: windows-latest
1716
steps:
18-
- name: 🔍 GH_TOKEN
19-
if: env.GH_TOKEN == ''
20-
shell: bash
21-
env:
22-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
17+
- name: 🤖 defaults
18+
uses: devlooped/actions-bot@v1
19+
with:
20+
name: ${{ secrets.BOT_NAME }}
21+
email: ${{ secrets.BOT_EMAIL }}
22+
gh_token: ${{ secrets.GH_TOKEN }}
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: 🤘 checkout
26+
uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
ref: main
30+
token: ${{ env.GH_TOKEN }}
2431

2532
- name: ⌛ rate
2633
shell: pwsh
@@ -38,13 +45,6 @@ jobs:
3845
echo "Rate limit has reset to $($rate.remaining) requests"
3946
}
4047
41-
- name: 🤘 checkout
42-
uses: actions/checkout@v2
43-
with:
44-
fetch-depth: 0
45-
ref: main
46-
token: ${{ env.GH_TOKEN }}
47-
4848
- name: 🔄 sync
4949
shell: pwsh
5050
run: |
@@ -63,16 +63,24 @@ jobs:
6363
echo 'No changelog was generated'
6464
}
6565
66+
- name: +Mᐁ includes
67+
uses: devlooped/actions-include@v1
68+
with:
69+
validate: false
70+
6671
- name: ✍ pull request
6772
uses: peter-evans/create-pull-request@v3
73+
continue-on-error: true
6874
with:
6975
base: main
7076
branch: dotnet-file-sync
7177
delete-branch: true
7278
labels: dependencies
79+
author: ${{ env.BOT_AUTHOR }}
80+
committer: ${{ env.BOT_AUTHOR }}
7381
commit-message: ⬆️ Bump files with dotnet-file sync
7482

7583
${{ env.CHANGES }}
76-
title: "Bump files with dotnet-file sync"
84+
title: "⬆️ Bump files with dotnet-file sync"
7785
body: ${{ env.CHANGES }}
7886
token: ${{ env.GH_TOKEN }}

0 commit comments

Comments
 (0)