Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude directories option #101

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ inputs:
[Optional] create target branch if not exist. Defaults to `false`
default: false
required: false
exclude-directories:
description: '[Optional] The directory to exclude for remove from remote repo'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be changed to say something like

ignore-directories:
  description: '[Optional] whitespace delimited set of directories to ignore.'

It feels like a different naming makes it more obvious that the directories will be ignored in the overall process.

default: ''
required: false

runs:
using: docker
Expand All @@ -71,6 +75,7 @@ runs:
- '${{ inputs.commit-message }}'
- '${{ inputs.target-directory }}'
- '${{ inputs.create-target-branch-if-needed }}'
- '${{ inputs.exclude-directories }}'
branding:
icon: git-commit
color: green
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TARGET_BRANCH="${9}"
COMMIT_MESSAGE="${10}"
TARGET_DIRECTORY="${11}"
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
EXCLUDE_DIRECTORIES="${13}"

if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
then
Expand Down Expand Up @@ -115,7 +116,7 @@ mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"

echo "[+] List contents of $SOURCE_DIRECTORY"
ls "$SOURCE_DIRECTORY"

rm -rf "$SOURCE_DIRECTORY/.git"
echo "[+] Checking if local $SOURCE_DIRECTORY exist"
if [ ! -d "$SOURCE_DIRECTORY" ]
then
Expand All @@ -136,6 +137,7 @@ cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY"
cd "$CLONE_DIR"

echo "[+] Files that will be pushed"
chown -R $(id -u):$(id -g) .
ls -la

ORIGIN_COMMIT="https://$GITHUB_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
Expand All @@ -155,7 +157,12 @@ fi

echo "[+] Adding git commit"
git add .

if [ -n "$EXCLUDE_DIRECTORIES" ]
then
echo "[+] Checkout excluded dirs"
git reset -- $(echo $EXCLUDE_DIRECTORIES)
git restore $(echo $EXCLUDE_DIRECTORIES)
fi
echo "[+] git status:"
git status

Expand Down