Skip to content

Commit 08fb238

Browse files
committed
chore: Include ncc build of the project and few other changes
1 parent bdfd681 commit 08fb238

File tree

10 files changed

+8616
-49
lines changed

10 files changed

+8616
-49
lines changed

.github/workflows/actions_release.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ on:
66
tag:
77
description: "Tag for the release"
88
required: true
9-
script:
10-
description: "Specify the build script to run"
11-
required: false
12-
type: string
13-
default: "npm run test"
149

1510
permissions:
1611
contents: read
@@ -24,5 +19,4 @@ jobs:
2419

2520
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
2621
with:
27-
tag: "${{ github.event.inputs.tag }}"
28-
script: ${{ github.event.inputs.script || 'npm run test'}}
22+
tag: "${{ github.event.inputs.tag }}"

.github/workflows/audit_package.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ on:
1111
description: "Specify a base branch"
1212
required: false
1313
default: "main"
14-
script:
15-
description: "Specify the build script to run"
16-
required: false
17-
type: string
18-
default: "npm run test"
1914
schedule:
2015
- cron: "0 0 * * 1"
2116

@@ -25,7 +20,6 @@ jobs:
2520
with:
2621
force: ${{ inputs.force || false }}
2722
base_branch: ${{ inputs.base_branch || 'main' }}
28-
script: ${{ github.event.inputs.script || 'npm run test' }}
2923

3024
permissions:
3125
contents: write

.github/workflows/git-auto-commit.yml

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

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2025 StepSecurity
43
Copyright (c) 2021 Stefan Zweifel
4+
Copyright (c) 2025 StepSecurity
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ The example below can be used as a starting point to generate a multiline commit
286286
### Signing Commits
287287

288288
If you would like to sign your commits using a GPG key, you will need to use an additional action.
289-
You can use the [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) action and follow its setup instructions.
289+
You can use the [step-security/ghaction-import-gpg](https://github.com/step-security/ghaction-import-gpg) action and follow its setup instructions.
290290

291291
As git-auto-commit by default does not use **your** username and email when creating a commit, you have to override these values in your workflow.
292292

293293
```yml
294294
- name: "Import GPG key"
295295
id: import-gpg
296-
uses: crazy-max/ghaction-import-gpg@v6
296+
uses: step-security/ghaction-import-gpg@v6
297297
with:
298298
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
299299
passphrase: ${{ secrets.GPG_PASSPHRASE }}

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ outputs:
8686

8787
runs:
8888
using: 'node20'
89-
main: 'index.js'
89+
main: 'dist/index.js'
9090

9191
branding:
9292
icon: 'git-commit'

dist/entrypoint.sh

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
if "$INPUT_DISABLE_GLOBBING"; then
6+
set -o noglob;
7+
fi
8+
9+
_set_github_output() {
10+
local name=${1}
11+
local value=${2}
12+
13+
# Check if $GITHUB_OUTPUT is available
14+
# (Feature detection will be removed in spring 2023)
15+
if [ -z ${GITHUB_OUTPUT+x} ]; then
16+
echo "::set-output name=$name::$value";
17+
else
18+
echo "$name=$value" >> $GITHUB_OUTPUT;
19+
fi
20+
}
21+
22+
_log() {
23+
local level=${1}
24+
local message=${2}
25+
26+
echo "::$level::$message";
27+
}
28+
29+
_main() {
30+
_check_if_git_is_available
31+
32+
_switch_to_repository
33+
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
34+
_log "debug" "Create git tag only";
35+
_set_github_output "create_git_tag_only" "true"
36+
_tag_commit
37+
_push_to_github
38+
elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
39+
40+
_set_github_output "changes_detected" "true"
41+
42+
_switch_to_branch
43+
44+
_add_files
45+
46+
# Check dirty state of repo again using git-diff.
47+
# (git-diff detects better if CRLF of files changes and does NOT
48+
# proceed, if only CRLF changes are detected. See #241 and #265
49+
# for more details.)
50+
if [ -n "$(git diff --staged)" ] || "$INPUT_SKIP_DIRTY_CHECK"; then
51+
_local_commit
52+
53+
_tag_commit
54+
55+
_push_to_github
56+
else
57+
_set_github_output "changes_detected" "false"
58+
59+
echo "Working tree clean. Nothing to commit.";
60+
fi
61+
else
62+
_set_github_output "changes_detected" "false"
63+
64+
echo "Working tree clean. Nothing to commit.";
65+
fi
66+
}
67+
68+
_check_if_git_is_available() {
69+
if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then
70+
_log "debug" "git binary found.";
71+
else
72+
_log "error" "git-auto-commit could not find git binary. Please make sure git is available."
73+
exit 1;
74+
fi
75+
}
76+
77+
_switch_to_repository() {
78+
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
79+
cd "$INPUT_REPOSITORY";
80+
}
81+
82+
_git_is_dirty() {
83+
echo "INPUT_STATUS_OPTIONS: ${INPUT_STATUS_OPTIONS}";
84+
_log "debug" "Apply status options ${INPUT_STATUS_OPTIONS}";
85+
86+
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
87+
read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN";
88+
89+
# capture stderr
90+
gitStatusMessage="$((git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}} >/dev/null ) 2>&1)";
91+
# shellcheck disable=SC2086
92+
gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})";
93+
if [ $? -ne 0 ]; then
94+
_log "error" "git-status failed with:<$gitStatusMessage>";
95+
exit 1;
96+
fi
97+
[ -n "$gitStatus" ]
98+
}
99+
100+
_switch_to_branch() {
101+
echo "INPUT_BRANCH value: $INPUT_BRANCH";
102+
103+
# Fetch remote to make sure that repo can be switched to the right branch.
104+
if "$INPUT_SKIP_FETCH"; then
105+
_log "debug" "git-fetch will not be executed.";
106+
else
107+
git fetch --depth=1;
108+
fi
109+
110+
# If `skip_checkout`-input is true, skip the entire checkout step.
111+
if "$INPUT_SKIP_CHECKOUT"; then
112+
_log "debug" "git-checkout will not be executed.";
113+
else
114+
# Create new local branch if `create_branch`-input is true
115+
if "$INPUT_CREATE_BRANCH"; then
116+
# shellcheck disable=SC2086
117+
git checkout -B $INPUT_BRANCH --;
118+
else
119+
# Switch to branch from current Workflow run
120+
# shellcheck disable=SC2086
121+
git checkout $INPUT_BRANCH --;
122+
fi
123+
fi
124+
}
125+
126+
_add_files() {
127+
echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}";
128+
_log "debug" "Apply add options ${INPUT_ADD_OPTIONS}";
129+
130+
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
131+
read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN";
132+
133+
# shellcheck disable=SC2086
134+
git add ${INPUT_ADD_OPTIONS} ${INPUT_FILE_PATTERN:+"${INPUT_FILE_PATTERN_EXPANDED[@]}"};
135+
}
136+
137+
_local_commit() {
138+
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}";
139+
_log "debug" "Apply commit options ${INPUT_COMMIT_OPTIONS}";
140+
141+
# shellcheck disable=SC2206
142+
INPUT_COMMIT_OPTIONS_ARRAY=( $INPUT_COMMIT_OPTIONS );
143+
144+
echo "INPUT_COMMIT_USER_NAME: ${INPUT_COMMIT_USER_NAME}";
145+
echo "INPUT_COMMIT_USER_EMAIL: ${INPUT_COMMIT_USER_EMAIL}";
146+
echo "INPUT_COMMIT_MESSAGE: ${INPUT_COMMIT_MESSAGE}";
147+
echo "INPUT_COMMIT_AUTHOR: ${INPUT_COMMIT_AUTHOR}";
148+
149+
git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" \
150+
commit -m "$INPUT_COMMIT_MESSAGE" \
151+
--author="$INPUT_COMMIT_AUTHOR" \
152+
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
153+
154+
_set_github_output "commit_hash" $(git rev-parse HEAD)
155+
}
156+
157+
_tag_commit() {
158+
echo "INPUT_TAGGING_MESSAGE: ${INPUT_TAGGING_MESSAGE}"
159+
160+
if [ -n "$INPUT_TAGGING_MESSAGE" ]
161+
then
162+
_log "debug" "Create tag $INPUT_TAGGING_MESSAGE";
163+
git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE";
164+
else
165+
echo "No tagging message supplied. No tag will be added.";
166+
fi
167+
}
168+
169+
_push_to_github() {
170+
171+
echo "INPUT_PUSH_OPTIONS: ${INPUT_PUSH_OPTIONS}";
172+
_log "debug" "Apply push options ${INPUT_PUSH_OPTIONS}";
173+
174+
# shellcheck disable=SC2206
175+
INPUT_PUSH_OPTIONS_ARRAY=( $INPUT_PUSH_OPTIONS );
176+
177+
if [ -z "$INPUT_BRANCH" ]
178+
then
179+
# Only add `--tags` option, if `$INPUT_TAGGING_MESSAGE` is set
180+
if [ -n "$INPUT_TAGGING_MESSAGE" ]
181+
then
182+
_log "debug" "git push origin --tags";
183+
git push origin --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
184+
else
185+
_log "debug" "git push origin";
186+
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
187+
fi
188+
189+
else
190+
_log "debug" "Push commit to remote branch $INPUT_BRANCH";
191+
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
192+
fi
193+
}
194+
195+
_main

0 commit comments

Comments
 (0)