8000 Use BOT_ defaults consistently · devlooped/oss@98919f7 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 98919f7

Browse files
committed
Use BOT_ defaults consistently
1 parent 1d3a2f4 commit 98919f7

File tree

4 files changed

+79
-28
lines changed

4 files changed

+79
-28
lines changed

.github/workflows/changelog.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ on:
44
types: [released]
55
workflow_dispatch:
66

7-
env:
8-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
9-
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
11+
- name: 🔍 defaults
12+
uses: ./.github/workflows/defaults
1913

2014
- name: 🤘 checkout
2115
uses: actions/checkout@v2
@@ -36,7 +30,7 @@ jobs:
3630
3731
- name: 🚀 changelog
3832
run: |
39-
git config --local user.name github-actions
40-
git config --local user.email github-actions@github.com
33+
git config --local user.name ${BOT_NAME}
34+
git config --local user.email ${BOT_EMAIL}
4135
git add changelog.md
4236
(git commit -m "🖉 Update changelog with ${GITHUB_REF#refs/*/}" && git push) || echo "Done"

.github/workflows/defaults/action.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: test
2+
description: runs dotnet tests with retry
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: 🔍 GH_TOKEN
7+
if: env.GH_TOKEN == ''
8+
shell: bash
9+
env:
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
GH_TOKEN_SECRET: ${{ secrets.GH_TOKEN }}
12+
run: |
13+
if [ -z "${GH_TOKEN_SECRET}" ]
14+
then
15+
echo "Using default GITHUB_TOKEN"
16+
echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
17+
else
18+
echo "Using custom GH_TOKEN"
19+
echo "GH_TOKEN=${GH_TOKEN_SECRET}" >> $GITHUB_ENV
20+
fi
21+
22+
- name: 🔍 BOT_NAME
23+
if: env.BOT_NAME == ''
24+
shell: bash
25+
env:
26+
BOT_NAME_SECRET: ${{ secrets.BOT_NAME }}
27+
run: |
28+
if [ -z "${BOT_NAME_SECRET}" ]
29+
then
30+
echo "Using default GITHUB_AUTHOR as BOT_NAME"
31+
echo "BOT_NAME=${GITHUB_AUTHOR}" >> $GITHUB_ENV
32+
else
33+
echo "Using custom BOT_NAME"
34+
echo "BOT_NAME=${BOT_NAME_SECRET}" >> $GITHUB_ENV
35+
fi
36+
37+
- name: 🔍 BOT_EMAIL
38+
if: env.BOT_EMAIL == ''
39+
shell: bash
40+
env:
41+
BOT_EMAIL_SECRET: ${{ secrets.BOT_EMAIL }}
42+
run: |
43+
if [ -z "${BOT_EMAIL_SECRET}" ]
44+
then
45+
echo "Using default GITHUB_AUTHOR as BOT_EMAIL"
46+
echo "BOT_EMAIL=${GITHUB_AUTHOR}@users.noreply.github.com" >> $GITHUB_ENV
47+
else
48+
echo "Using custom BOT_EMAIL"
49+
echo "BOT_EMAIL=${BOT_EMAIL_SECRET}" >> $GITHUB_ENV
50+
fi
51+
52+
- name: 🔍 BOT_AUTHOR
53+
if: env.BOT_AUTHOR == ''
54+
shell: bash
55+
env:
56+
BOT_AUTHOR_SECRET: ${{ secrets.BOT_AUTHOR }}
57+
run: |
58+
if [ -z "${BOT_AUTHOR_SECRET}" ]
59+
then
60+
echo "Using default BOT_NAME <$BOT_EMAIL> as BOT_AUTHOR"
61+
echo "BOT_AUTHOR=${BOT_NAME} <${BOT_EMAIL}>" >> $GITHUB_ENV
62+
else
63+
echo "Using custom BOT_AUTHOR"
64+
echo "BOT_AUTHOR=${BOT_AUTHOR_SECRET}" >> $GITHUB_ENV
65+
fi

.github/workflows/dotnet-file.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,13 @@ on:
99

1010
env:
1111
DOTNET_NOLOGO: true
12-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
13-
BOT_AUTHOR: ${{ secrets.BOT_NAME }} <${{ secrets.BOT_EMAIL }}>
1412

1513
jobs:
1614
sync:
1715
runs-on: windows-latest
1816
steps:
19-
- name: 🔍 GH_TOKEN
20-
if: env.GH_TOKEN == ''
21-
shell: bash
22-
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
25-
26-
- name: 🔍 BOT_AUTHOR
27-
if: ${{ env.BOT_NAME == '' || env.BOT_EMAIL == '' }}
28-
shell: bash
29-
env:
30-
BOT_NAME: ${{ secrets.BOT_NAME }}
31-
BOT_EMAIL: ${{ secrets.BOT_EMAIL }}
32-
run: echo "BOT_AUTHOR=${GITHUB_AUTHOR} <${GITHUB_AUTHOR}@users.noreply.github.com>" >> $GITHUB_ENV
17+
- name: 🔍 defaults
18+
uses: ./.github/workflows/defaults
3319

3420
- name: ⌛ rate
3521
shell: pwsh
@@ -79,10 +65,10 @@ jobs:
7965
branch: dotnet-file-sync
8066
delete-branch: true
8167
labels: dependencies
68+
committer: ${{ env.BOT_AUTHOR }}
8269
commit-message: ⬆️ Bump files with dotnet-file sync
8370

8471
${{ env.CHANGES }}
8572
title: "⬆️ Bump files with dotnet-file sync"
8673
body: ${{ env.CHANGES }}
87-
token: ${{ env.GH_TOKEN }}
88-
author: ${{ env.BOT_AUTHOR }}
74+
token: ${{ env.GH_TOKEN }}

.github/workflows/includes.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
includes:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- name: 🔍 defaults
15+
uses: ./.github/workflows/defaults
16+
1417
- name: 🤘 checkout
1518
uses: actions/checkout@v2
1619

@@ -23,6 +26,9 @@ jobs:
2326
base: main
2427
branch: markdown-includes
2528
delete-branch: true
29+
labels: dependencies
30+
committer: ${{ env.BOT_AUTHOR }}
2631
commit-message: +M▼ includes
2732
title: +M▼ includes
2833
body: +M▼ includes
34+
token: ${{ env.GH_TOKEN }}

0 commit comments

Comments
 (0)
0