Skip to content

Commit f2e52f7

Browse files
committed
Switch to reusable workflow for dotnet-file
1 parent 42704be commit f2e52f7

File tree

2 files changed

+87
-73
lines changed

2 files changed

+87
-73
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Synchronizes .netconfig-configured files with dotnet-file
2+
name: dotnet-file-core
3+
on:
4+
workflow_call:
5+
6+
env:
7+
DOTNET_NOLOGO: true
8+
9+
defaults:
10+
run:
11+
shell: pwsh
12+
13+
jobs:
14+
sync:
15+
runs-on: windows-latest
16+
continue-on-error: true
17+
steps:
18+
- name: 🤖 defaults
19+
uses: devlooped/actions-bot@v1
20+
with:
21+
name: ${{ secrets.BOT_NAME }}
22+
email: ${{ secrets.BOT_EMAIL }}
23+
gh_token: ${{ secrets.GH_TOKEN }}
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: 🤘 checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
ref: main
31+
token: ${{ env.GH_TOKEN }}
32+
33+
- name: ⌛ rate
34+
if: github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call'
35+
run: |
36+
# add random sleep since we run on fixed schedule
37+
sleep (get-random -max 60)
38+
# get currently authenticated user rate limit info
39+
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
40+
# if we don't have at least 100 requests left, wait until reset
41+
if ($rate.remaining -lt 10) {
42+
$wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s))
43+
echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset"
44+
sleep $wait
45+
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
46+
echo "Rate limit has reset to $($rate.remaining) requests"
47+
}
48+
49+
- name: 🔄 sync
50+
run: |
51+
dotnet tool update -g dotnet-gcm
52+
dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN
53+
gh auth status
54+
55+
dotnet tool update -g dotnet-file
56+
dotnet file sync -c:$env:TEMP\dotnet-file.md
57+
if (test-path $env:TEMP\dotnet-file.md) {
58+
echo 'CHANGES<<EOF' >> $env:GITHUB_ENV
59+
cat $env:TEMP\dotnet-file.md >> $env:GITHUB_ENV
60+
echo 'EOF' >> $env:GITHUB_ENV
61+
cat $env:TEMP\dotnet-file.md
62+
} else {
63+
echo 'No changelog was generated'
64+
}
65+
66+
- name: +Mᐁ includes
67+
uses: devlooped/actions-include@v1
68+
with:
69+
validate: false
70+
71+
- name: ✍ pull request
72+
uses: peter-evans/create-pull-request@v7
73+
with:
74+
base: main
75+
branch: dotnet-file-sync
76+
delete-branch: true
77+
labels: dependencies
78+
author: ${{ env.BOT_AUTHOR }}
79+
committer: ${{ env.BOT_AUTHOR }}
80+
commit-message: ⬆️ Bump files with dotnet-file sync
81+
82+
${{ env.CHANGES }}
83+
title: "⬆️ Bump files with dotnet-file sync"
84+
body: ${{ env.CHANGES }}
85+
token: ${{ env.GH_TOKEN }}

.github/workflows/dotnet-file.yml

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -12,76 +12,5 @@ env:
1212

1313
jobs:
1414
sync:
15-
runs-on: windows-latest
16-
continue-on-error: true
17-
steps:
18-
- name: 🤖 defaults
19-
uses: devlooped/actions-bot@v1
20-
with:
21-
name: ${{ secrets.BOT_NAME }}
22-
email: ${{ secrets.BOT_EMAIL }}
23-
gh_token: ${{ secrets.GH_TOKEN }}
24-
github_token: ${{ secrets.GITHUB_TOKEN }}
25-
26-
- name: 🤘 checkout
27-
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
30-
ref: main
31-
token: ${{ env.GH_TOKEN }}
32-
33-
- name: ⌛ rate
34-
shell: pwsh
35-
if: github.event_name != 'workflow_dispatch'
36-
run: |
37-
# add random sleep since we run on fixed schedule
38-
sleep (get-random -max 60)
39-
# get currently authenticated user rate limit info
40-
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
41-
# if we don't have at least 100 requests left, wait until reset
42-
if ($rate.remaining -lt 10) {
43-
$wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s))
44-
echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset"
45-
sleep $wait
46-
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
47-
echo "Rate limit has reset to $($rate.remaining) requests"
48-
}
49-
50-
- name: 🔄 sync
51-
shell: pwsh
52-
run: |
53-
dotnet tool update -g dotnet-gcm
54-
dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN
55-
gh auth status
56-
57-
dotnet tool update -g dotnet-file
58-
dotnet file sync -c:$env:TEMP\dotnet-file.md
59-
if (test-path $env:TEMP\dotnet-file.md) {
60-
echo 'CHANGES<<EOF' >> $env:GITHUB_ENV
61-
cat $env:TEMP\dotnet-file.md >> $env:GITHUB_ENV
62-
echo 'EOF' >> $env:GITHUB_ENV
63-
cat $env:TEMP\dotnet-file.md
64-
} else {
65-
echo 'No changelog was generated'
66-
}
67-
68-
- name: +Mᐁ includes
69-
uses: devlooped/actions-include@v1
70-
with:
71-
validate: false
72-
73-
- name: ✍ pull request
74-
uses: peter-evans/create-pull-request@v7
75-
with:
76-
base: main
77-
branch: dotnet-file-sync
78-
delete-branch: true
79-
labels: dependencies
80-
author: ${{ env.BOT_AUTHOR }}
81-
committer: ${{ env.BOT_AUTHOR }}
82-
commit-message: ⬆️ Bump files with dotnet-file sync
83-
84-
${{ env.CHANGES }}
85-
title: "⬆️ Bump files with dotnet-file sync"
86-
body: ${{ env.CHANGES }}
87-
token: ${{ env.GH_TOKEN }}
15+
uses: devlooped/oss/.github/workflows/dotnet-file-core.yml@reusable
16+
secrets: inherit

0 commit comments

Comments
 (0)