Skip to content

Commit 61d14d1

Browse files
authored
Merge pull request #24 from EndBug/ncc
Use @zeit/ncc for builds
2 parents a28158a + 6a75638 commit 61d14d1

File tree

7 files changed

+109
-671
lines changed

7 files changed

+109
-671
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inputs:
3131

3232
runs:
3333
using: node12
34-
main: lib/main.js
34+
main: lib/index.js
3535

3636
branding:
3737
icon: git-commit

lib/entrypoint.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
set -u
3+
4+
cd $INPUT_CWD
5+
echo "Running in $PWD."
6+
7+
# Set up .netrc file with GitHub credentials
8+
git_setup() {
9+
cat <<-EOF >$HOME/.netrc
10+
machine github.com
11+
login $GITHUB_ACTOR
12+
password $GITHUB_TOKEN
13+
14+
machine api.github.com
15+
login $GITHUB_ACTOR
16+
password $GITHUB_TOKEN
17+
EOF
18+
chmod 600 $HOME/.netrc
19+
git config --global user.email "$INPUT_AUTHOR_EMAIL"
20+
git config --global user.name "$INPUT_AUTHOR_NAME"
21+
}
22+
23+
add() {
24+
if $INPUT_FORCE; then f=-f; else f=; fi
25+
git add $INPUT_ADD $f
26+
}
27+
28+
remove() {
29+
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
30+
}
31+
32+
# This is needed to make the check work for untracked files
33+
echo "Staging files..."
34+
add
35+
remove
36+
37+
echo "Checking for uncommitted changes in the git working tree..."
38+
# This section only runs if there have been file changes
39+
if ! git diff --cached --exit-code; then
40+
git_setup
41+
42+
git fetch
43+
44+
# Verify if the branch needs to be created
45+
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"; then
46+
echo "Creating branch..."
47+
git branch "${GITHUB_REF:11}"
48+
fi
49+
50+
# Switch to branch from current workflow run
51+
echo "Switching branch..."
52+
git checkout "${GITHUB_REF:11}"
53+
54+
echo "Pulling from remote..."
55+
git fetch && git pull
56+
57+
echo "Resetting files..."
58+
git reset
59+
60+
echo "Adding files..."
61+
add
62+
63+
echo "Removing files..."
64+
remove
65+
66+
echo "Creating commit..."
67+
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
68+
69+
echo "Pushing to repo..."
70+
git push --set-upstream origin "${GITHUB_REF:11}"
71+
else
72+
echo "Working tree clean. Nothing to commit."
73+
fi

lib/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)