Skip to content

Commit eb5215a

Browse files
committed
Trying to allow excluding a path
1 parent e189e38 commit eb5215a

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.github/workflows/apply-reuse.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ jobs:
8181

8282
- name: Commit and push changes
8383
id: push
84-
uses: UoMResearchIT/actions/git-push-changes-to-branch@main
84+
uses: UoMResearchIT/actions/git-push-changes-to-branch@omit-workflows-from-commits
8585
with:
8686
working-directory: ${{ inputs.work-dir }}
8787
branch-prefix: add-license-headers-to
8888
commit-message: Add License and Copyright Headers
89+
exclude: .github/workflows/*
8990

9091
annotate:
9192
runs-on: ubuntu-latest

git-push-changes-to-branch/action.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inputs:
4747
description: >
4848
The email address of the user to ascribe the commit to.
4949
default: no-reply@github.com
50+
exclude:
51+
description: >
52+
A pattern to describe what files to omit from the committed.
53+
default: ""
5054
outputs:
5155
branch:
5256
description: >
@@ -55,7 +59,7 @@ outputs:
5559
changed:
5660
description: >
5761
Whether there were any changes committed.
58-
value: ${{ steps.detect.outputs.changed }}
62+
value: ${{ steps.push.outputs.work == 1 }}
5963
runs:
6064
using: composite
6165
steps:
@@ -92,14 +96,25 @@ runs:
9296
USER_EMAIL: ${{ inputs.commit-user-email }}
9397
- name: push changes
9498
if: steps.detect.outputs.changed == 1
99+
id: push
95100
working-directory: ${{ inputs.working-directory }}
96101
run: |
97102
git checkout -b "$NEW_BRANCH"
98-
git add -A
99-
git commit -a -m "$MESSAGE"
100-
git push origin "$NEW_BRANCH"
103+
if [ -z "$EXCLUDE" ]; then
104+
git add -A
105+
else
106+
git add --all -- "${EXCLUDE/#/:!}"
107+
fi
108+
if git diff --cached --exit-code >/dev/null; then
109+
echo "work=0" >> $GITHUB_OUTPUT
110+
else
111+
git commit -a -m "$MESSAGE"
112+
git push origin "$NEW_BRANCH"
113+
echo "work=1" >> $GITHUB_OUTPUT
114+
fi
101115
shell: bash
102116
env:
103117
GH_TOKEN: ${{ inputs.token }}
104118
NEW_BRANCH: ${{ steps.name.outputs.branch }}
105119
MESSAGE: ${{ inputs.commit-message }}
120+
EXCLUDE: ${{ inputs.exclude }}

0 commit comments

Comments
 (0)