Skip to content

Commit 8f168fe

Browse files
authored
fix: Fixes for docker hub image (#28)
* fix: Fixes for docker hub image (INPUT_EMPTYCOMMITS false condition) * fix: Add skip function Close #27 Close #31 Keep open #29 * gha: Add fetch-depth 1 to actions/checkout * gha: Add pull_request trigger, Close #32
1 parent 5a72c92 commit 8f168fe

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.github/workflows/docker-image-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: docker image ci
22

33
on:
4+
pull_request:
5+
types: [opened, synchronize]
46
push:
57
paths:
68
- '**'
9+
- '.**'
710
- '!LICENSE'
811
- '!README.md'
912
- '!images'
@@ -14,6 +17,8 @@ jobs:
1417

1518
steps:
1619
- uses: actions/checkout@master
20+
with:
21+
fetch-depth: 1
1722

1823
- name: build
1924
env:
@@ -26,13 +31,17 @@ jobs:
2631
runs-on: ubuntu-18.04
2732
steps:
2833
- uses: actions/checkout@master
34+
with:
35+
fetch-depth: 1
2936
- name: shellcheck
3037
run: shellcheck ./entrypoint.sh
3138

3239
hadolint:
3340
runs-on: macOS-10.14
3441
steps:
3542
- uses: actions/checkout@master
43+
with:
44+
fetch-depth: 1
3645
- name: hadolint
3746
run: |
3847
brew install hadolint

entrypoint.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ function print_info() {
1111
echo -e "\e[36mINFO: ${1}\e[m"
1212
}
1313

14+
function skip() {
15+
print_info "No changes detected, skipping deployment"
16+
exit 0
17+
}
18+
1419
# check values
1520
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
1621

@@ -32,6 +37,7 @@ elif [ -n "${PERSONAL_TOKEN}" ]; then
3237
elif [ -n "${GITHUB_TOKEN}" ]; then
3338

3439
print_info "setup with GITHUB_TOKEN"
40+
print_error "Do not use GITHUB_TOKEN, See #9"
3541

3642
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
3743

@@ -74,12 +80,10 @@ git add --all
7480

7581
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
7682
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
77-
if [[ ${INPUT_EMPTYCOMMITS} == "true" ]]; then
78-
git commit --allow-empty -m "${COMMIT_MESSAGE}"
83+
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
84+
git commit -m "${COMMIT_MESSAGE}" || skip
7985
else
80-
git commit -m "${COMMIT_MESSAGE}" || \
81-
print_info "No changes detected, skipping deployment" && \
82-
exit 0
86+
git commit --allow-empty -m "${COMMIT_MESSAGE}"
8387
fi
8488

8589
git push origin "${remote_branch}"

0 commit comments

Comments
 (0)