Skip to content

Commit 7ba7f0e

Browse files
committed
refactor: Consolidate GitHub credentials and git operations in workflows
1 parent 30dae43 commit 7ba7f0e

5 files changed

Lines changed: 69 additions & 114 deletions

File tree

.github/workflows/gittools-actions.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@ jobs:
3232
$version = "${{ github.event.inputs.tag-name }}"
3333
}
3434
"version=$version" >> $env:GITHUB_OUTPUT
35-
-
36-
name: Load GitHub App credentials
37-
id: gh-app-creds
38-
uses: gittools/cicd/gh-app-creds@v1
35+
36+
- name: Load GitHub App credentials
37+
id: github-app-creds
38+
uses: gittools/cicd/github-app-creds@v1
3939
with:
4040
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
41-
-
42-
name: Generate GitHub App Token
41+
42+
- name: Generate GitHub App Token
4343
id: app-token
4444
uses: actions/create-github-app-token@v3
4545
with:
46-
app-id: ${{ steps.gh-app-creds.outputs.gh_app_id }}
47-
private-key: ${{ steps.gh-app-creds.outputs.gh_app_private_key }}
46+
app-id: ${{ steps.github-app-creds.outputs.gh_app_id }}
47+
private-key: ${{ steps.github-app-creds.outputs.gh_app_private_key }}
4848
owner: ${{ github.repository_owner }}
4949
repositories: actions
5050
permission-contents: write
51-
-
52-
uses: peter-evans/repository-dispatch@v4
51+
52+
- uses: peter-evans/repository-dispatch@v4
5353
name: Update GitTools Actions
5454
with:
5555
token: ${{ steps.app-token.outputs.token }}

.github/workflows/homebrew.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,23 @@ jobs:
2828
$version = "${{ github.event.inputs.tag-name }}"
2929
}
3030
"version=$version" >> $env:GITHUB_OUTPUT
31-
-
32-
name: Load GitHub App credentials
33-
id: gh-app-creds
34-
uses: gittools/cicd/gh-app-creds@v1
31+
32+
- name: Load GitHub release token
33+
id: github-creds
34+
uses: gittools/cicd/github-creds@v1
3535
with:
3636
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
37-
-
38-
name: Generate GitHub App Token
39-
id: app-token
40-
uses: actions/create-github-app-token@v3
41-
with:
42-
app-id: ${{ steps.gh-app-creds.outputs.gh_app_id }}
43-
private-key: ${{ steps.gh-app-creds.outputs.gh_app_private_key }}
44-
owner: ${{ github.repository_owner }}
45-
repositories: homebrew-core
46-
permission-contents: write
47-
permission-pull-requests: write
48-
-
49-
uses: mislav/bump-homebrew-formula-action@v3
37+
38+
- uses: mislav/bump-homebrew-formula-action@v3
5039
name: Bump Homebrew formula
5140
with:
5241
formula-name: gitversion
5342
tag-name: ${{ steps.get-version.outputs.version }}
5443
download-url: https://github.com/GitTools/GitVersion/archive/refs/tags/${{ steps.get-version.outputs.version }}.tar.gz
55-
push-to: ${{ github.repository_owner }}/homebrew-core
44+
push-to: gittools-bot/homebrew-core
5645
commit-message: |
5746
{{formulaName}} {{version}}
5847
5948
For additional details see https://github.com/GitTools/GitVersion/releases/tag/${{ steps.get-version.outputs.version }}
6049
env:
61-
COMMITTER_TOKEN: ${{ steps.app-token.outputs.token }}
50+
COMMITTER_TOKEN: ${{ steps.github-creds.outputs.github_release_token }}

.github/workflows/mkdocs.yml

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,27 @@ defaults:
2424

2525
jobs:
2626
docs:
27-
permissions:
28-
contents: write
2927
name: Update Markdown (embedded snippets)
3028
runs-on: ubuntu-24.04
3129
steps:
32-
-
33-
name: Checkout
34-
uses: actions/checkout@v6
35-
if: github.event_name == 'push'
36-
-
37-
name: Checkout
38-
uses: actions/checkout@v6
39-
if: github.event_name == 'pull_request'
40-
-
41-
name: Setup .NET SDK
30+
- name: Checkout
31+
uses: gittools/cicd/checkout@v1
32+
with:
33+
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
34+
fetch-depth: 1
35+
36+
- name: Setup .NET SDK
4237
uses: actions/setup-dotnet@v5
4338
with:
4439
global-json-file: global.json
45-
-
46-
name: Run MarkdownSnippets
40+
41+
- name: Run MarkdownSnippets
4742
run: |
4843
dotnet tool install --global MarkdownSnippets.Tool
4944
mdsnippets --write-header false
5045
working-directory: ${{ github.workspace }}/docs/input
51-
-
52-
name: Check for changes
53-
id: status
54-
run: |
55-
if ($null -ne (git status --porcelain)) { echo "has_changes=1"; echo "has_changes=1" >> $env:GITHUB_OUTPUT }
56-
-
57-
name: Push changes
58-
run: |
59-
git add --verbose .
60-
git config user.name 'gittools-bot'
61-
git config user.email 'gittoolsbot@outlook.com'
62-
git commit -m 'Docs changes' --allow-empty
63-
git push --force
64-
if: steps.status.outputs.has_changes == '1' && github.event_name == 'push'
46+
47+
- name: Commit and push markdown docs changes
48+
uses: gittools/cicd/git-commit-push@v1
49+
with:
50+
message: "include markdown docs changes"

.github/workflows/public-api.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,19 @@ defaults:
1111

1212
jobs:
1313
public-api:
14-
permissions:
15-
contents: write
1614
name: Mark public API as shipped
1715
runs-on: ubuntu-24.04
1816
steps:
19-
-
20-
name: Checkout
21-
uses: actions/checkout@v6
22-
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
23-
-
24-
name: Mark public API as shipped
17+
- name: Checkout
18+
uses: gittools/cicd/checkout@v1
19+
with:
20+
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
21+
fetch-depth: 0
22+
23+
- name: Mark public API as shipped
2524
run: ./src/mark-shipped.ps1
26-
-
27-
name: Check for changes
28-
id: status
29-
run: |
30-
if ($null -ne (git status --porcelain)) { echo "has_changes=1"; echo "has_changes=1" >> $env:GITHUB_OUTPUT }
31-
-
32-
name: Push changes
33-
run: |
34-
git add --verbose .
35-
git config user.name 'gittools-bot'
36-
git config user.email 'gittoolsbot@outlook.com'
37-
git commit -m 'Mark public API as shipped' --allow-empty
38-
git push --force
39-
if: steps.status.outputs.has_changes == '1'
25+
26+
- name: Commit and push changes
27+
uses: gittools/cicd/git-commit-push@v1
28+
with:
29+
message: "include public API changes"

.github/workflows/winget.yml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,34 @@ permissions:
1414

1515
jobs:
1616
homebrew:
17-
permissions:
18-
contents: none
1917
name: Bump winget manifest
2018
runs-on: ubuntu-24.04
2119
steps:
22-
- name: Load GitHub App credentials
23-
id: gh-app-creds
24-
uses: gittools/cicd/gh-app-creds@v1
25-
with:
26-
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
27-
- name: Generate GitHub App Token
28-
id: app-token
29-
uses: actions/create-github-app-token@v3
30-
with:
31-
app-id: ${{ steps.gh-app-creds.outputs.gh_app_id }}
32-
private-key: ${{ steps.gh-app-creds.outputs.gh_app_private_key }}
33-
owner: ${{ github.repository_owner }}
34-
repositories: winget-pkgs
35-
permission-contents: write
36-
permission-pull-requests: write
37-
- name: Get version
38-
id: get-version
39-
shell: pwsh
40-
run: |
41-
$version = "${{ github.event.client_payload.tag }}"
42-
if ($version -eq "") {
43-
$version = "${{ github.event.inputs.tag-name }}"
44-
}
20+
- name: Get version
21+
id: get-version
22+
shell: pwsh
23+
run: |
24+
$version = "${{ github.event.client_payload.tag }}"
25+
if ($version -eq "") {
26+
$version = "${{ github.event.inputs.tag-name }}"
27+
}
4528
46-
$url = "https://github.com/GitTools/GitVersion/releases/download/{0}/gitversion-win-{1}-{0}.zip"
47-
$urls = @(($url -f $version, "x64"), ($url -f $version, "arm64")) -Join " "
29+
$url = "https://github.com/GitTools/GitVersion/releases/download/{0}/gitversion-win-{1}-{0}.zip"
30+
$urls = @(($url -f $version, "x64"), ($url -f $version, "arm64")) -Join " "
4831
49-
$run_args = "update GitTools.GitVersion --version $version --urls $urls --submit"
50-
"version=$version" >> $env:GITHUB_OUTPUT
51-
"run_args=$run_args" >> $env:GITHUB_OUTPUT
32+
$run_args = "update GitTools.GitVersion --version $version --urls $urls --submit"
33+
"version=$version" >> $env:GITHUB_OUTPUT
34+
"run_args=$run_args" >> $env:GITHUB_OUTPUT
5235
53-
- uses: michidk/run-komac@v2.1.0
54-
env:
55-
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
56-
with:
57-
args: '${{ steps.get-version.outputs.run_args }}'
36+
- name: Load GitHub release token
37+
id: github-creds
38+
uses: gittools/cicd/github-creds@v1
39+
with:
40+
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
41+
42+
- uses: michidk/run-komac@v2.1.0
43+
env:
44+
GITHUB_TOKEN: ${{ steps.github-creds.outputs.github_release_token }}
45+
with:
46+
args: '${{ steps.get-version.outputs.run_args }}'
47+
custom-fork-owner: gittools-bot

0 commit comments

Comments
 (0)