Skip to content

Commit 330d345

Browse files
committed
refact
1 parent f8e8b5e commit 330d345

File tree

3 files changed

+17
-143
lines changed

3 files changed

+17
-143
lines changed

.github/actions/push-changes/action.yml

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ author: 'Pete Sramek'
33
description: 'Push changes to a specified branch in the repository.'
44
inputs:
55
# Required
6-
artifact-name:
7-
description: 'Name of the artifact to download before pushing changes.'
8-
required: true
9-
working-directory:
10-
description: 'The working directory where the changes will be pushed from.'
11-
required: true
126
commit-message:
137
description: 'The commit message to use when pushing changes.'
148
required: true
@@ -17,9 +11,18 @@ inputs:
1711
description: '.NET SDK version. Default: 9.x'
1812
required: false
1913
default: '9.x'
14+
artifact-name:
15+
description: 'Name of the artifact to download before pushing changes. Default: '''''
16+
required: false
17+
default: ''
18+
working-directory:
19+
description: 'The working directory where the changes will be pushed from. Default ''.'''
20+
required: false
21+
default: '.'
2022
target-branch:
21-
description: 'The branch to push changes to.'
23+
description: 'The branch to push changes to.. Default: '''''
2224
required: false
25+
default: ''
2326

2427
runs:
2528
using: "composite"
@@ -33,6 +36,7 @@ runs:
3336
dotnet-version: ${{ env.dotnet-sdk-version }}
3437

3538
- name: Download a single artifact
39+
if: ${{ inputs.artifact-name != '' }}
3640
uses: actions/download-artifact@v4
3741
with:
3842
name: ${{ inputs.artifact-name }}
@@ -92,49 +96,4 @@ runs:
9296
git commit -m '${{ inputs.commit-message }}'
9397
git pull --rebase origin ${{ github.head_ref || github.ref }}
9498
git push
95-
working-directory: ${{ inputs.working-directory }}
96-
97-
# - name: Add changes from ${{ inputs.working-directory }}
98-
# shell: bash
99-
# run: |
100-
# git fetch origin
101-
# git config --global user.name "${{ github.actor }}"
102-
# git config --global user.email "${{ github.actor }}@users.noreply.github.com"
103-
# git add -- ${{ inputs.working-directory }}
104-
# - name: Create or switch to ${{ inputs.target-branch }}
105-
# if: ${{ inputs.target-branch != '' }}
106-
# shell: bash
107-
# run: |
108-
# git fetch origin
109-
# git stash push --keep-index -- ${{ inputs.working-directory }}
110-
# if git show-ref --verify --quiet refs/heads/${{ inputs.target-branch }}; then
111-
# echo "Branch ${{ inputs.target-branch }} already exists, switching to it."
112-
# git checkout ${{ inputs.target-branch }} --force
113-
# else
114-
# echo "Branch ${{ inputs.target-branch }} does not exist, creating it."
115-
# git checkout -b ${{ inputs.target-branch }} origin/${{ inputs.target-branch }} --force || git checkout -b ${{ inputs.target-branch }} --force
116-
# fi
117-
# git stash apply
118-
# - name: Check for changes in ${{ inputs.working-directory }}
119-
# shell: bash
120-
# run: |
121-
# git diff --staged --quiet -- ${{ inputs.working-directory }}
122-
# continue-on-error: true
123-
# id: check-diff
124-
# - name: Push changes to ${{ inputs.target-branch }}, if exists
125-
# if: ${{ steps.check-diff.outcome == 'success' }}
126-
# shell: bash
127-
# run: |
128-
# echo "No changes to commit in ${{ inputs.working-directory }}"
129-
# - name: Push changes to ${{ inputs.target-branch }}, if exists
130-
# if: ${{ steps.check-diff.outcome == 'failure' }}
131-
# shell: bash
132-
# run: |
133-
# git reset --hard
134-
# git stash pop
135-
# git commit -m'${{ inputs.commit-message }}' -- ${{ inputs.working-directory }}
136-
# git push
137-
# - name: Reset branch to ${{ github.ref }}
138-
# shell: bash
139-
# run: |
140-
# git checkout ${{ github.ref }}
99+
working-directory: ${{ inputs.working-directory }}

.github/workflows/create-new-version.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/format-cs-files.yml

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,12 @@ jobs:
3838

3939
- name: Format with .NET CLI
4040
run: |
41-
git checkout ${{ github.head_ref || github.ref }}
42-
git pull origin ${{ github.head_ref || github.ref }}
4341
dotnet format whitespace
4442
dotnet format style
4543
dotnet format analyzers --diagnostics IDE0005 IDE0073
4644
working-directory: ${{ github.workspace }}
47-
48-
- if: runner.os == 'Windows'
49-
run: |
50-
git config --global core.autocrlf false
51-
git config --global core.eol lf
52-
53-
- if: runner.os != 'Windows'
54-
run: |
55-
git config --global core.autocrlf true
56-
git config --global core.eol lf
57-
58-
- name: Validate with .NET ${{ vars.DOTNET_SDK_VERSION }}
59-
id: validate
60-
shell: bash
61-
run: |
62-
set +e
63-
git add .
64-
git diff --quiet --exit-code --cached
65-
echo has-changes="$?" >> $GITHUB_OUTPUT
66-
set -e
67-
working-directory: ${{ github.workspace }}
68-
69-
- name: Push changes to ${{ github.head_ref || github.ref }}
70-
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
71-
run: |
72-
git config user.name "$(git log -n 1 --pretty=format:%an)"
73-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
74-
git commit -m "applied file header rule"
75-
git pull origin ${{ github.head_ref || github.ref }}
76-
git push origin ${{ github.head_ref || github.ref }}
77-
working-directory: ${{ github.workspace }}
45+
46+
- name: 'Push changes'
47+
uses: './.github/actions/push-changes'
48+
with:
49+
commit-message: 'Formatted csharp files'

0 commit comments

Comments
 (0)