Skip to content

Commit

Permalink
Merge pull request #1 from DecimalTurn/dev
Browse files Browse the repository at this point in the history
Customize Git operations and a checks
  • Loading branch information
DecimalTurn authored Jul 7, 2024
2 parents 629cb2d + 6f1bfdb commit ffaf29f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ A simple GitHub Action to enforce CRLF on selected file types in your repo.

Example worflow:
```yml
name: Enforce-CRLF
name: Force CRLF for files inside the index

on:
push:
Expand All @@ -18,7 +18,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Enforce CRLF action
uses: DecimalTurn/Enforce-CRLF@v1
uses: DecimalTurn/Enforce-CRLF@main
with:
extensions: .bas, .frm, .cls
do-checkout: true
do-push: true
```
Note that in the above example, we are setting `do-checkout` and `do-push` in order to let Enforce-CRLF perform those steps for us. If however, you want Enforce-CRLF to be part of a more complex workflow where you've already performed the `git checkout` and/or will perform the `git push` at the end, you can always set those values to false.

```yml
do-checkout: false
do-push: false
```
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ inputs:
extensions:
description: 'List of extensions (including the dot) seperated by a comma.'
required: true
do-checkout:
description: 'Set to true in order to let the action perform the checkout for you (default = false).'
default: false
do-push:
description: 'Set to true in order to let the action perform the checkout for you (default = false).'
default: false
bot-name:
description: 'Name of the bot that will perform the commit.'
default: 'github-actions[bot]'
Expand All @@ -16,8 +22,27 @@ inputs:
runs:
using: "composite"
steps:
- name: Configure Git
run: |
git config --global core.autocrlf false
git config --global core.eol lf
shell: bash
- name: Checkout
if: ${{ inputs.do-checkout }}
uses: actions/checkout@v4
- name: Check EOL configs
run: |
IFS=',' read -r -a ext_array <<< "${{ inputs.extensions }}"
for ext in "${ext_array[@]}"; do
result=$(git check-attr text *"${ext}")
echo "$result"
if [[ $result == *"text: auto" || $result == *"text: text" ]]; then
echo "There is an issue with the ${ext} extension. The `text` attribute is set or it has a value of `auto` for that extension."
echo "This means that you won't be able to commit changes with CRLF. You need to make sure that `text` is unspecified or unset (-text)"
exit 1
fi
done
shell: bash
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
Expand All @@ -32,6 +57,7 @@ runs:
python '${{ github.action_path }}/enforce-crlf.py' "${{ inputs.extensions }}"
shell: bash
- name: Push content
if: ${{ inputs.do-push }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
Expand Down

0 comments on commit ffaf29f

Please sign in to comment.