Skip to content

Commit

Permalink
fix: Fixes for docker hub image (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
peaceiris committed Sep 23, 2019
1 parent 5a72c92 commit 8f168fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/docker-image-ci.yml
@@ -1,9 +1,12 @@
name: docker image ci

on:
pull_request:
types: [opened, synchronize]
push:
paths:
- '**'
- '.**'
- '!LICENSE'
- '!README.md'
- '!images'
Expand All @@ -14,6 +17,8 @@ jobs:

steps:
- uses: actions/checkout@master
with:
fetch-depth: 1

- name: build
env:
Expand All @@ -26,13 +31,17 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: shellcheck
run: shellcheck ./entrypoint.sh

hadolint:
runs-on: macOS-10.14
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: hadolint
run: |
brew install hadolint
Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Expand Up @@ -11,6 +11,11 @@ function print_info() {
echo -e "\e[36mINFO: ${1}\e[m"
}

function skip() {
print_info "No changes detected, skipping deployment"
exit 0
}

# check values
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then

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

print_info "setup with GITHUB_TOKEN"
print_error "Do not use GITHUB_TOKEN, See #9"

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

Expand Down Expand Up @@ -74,12 +80,10 @@ git add --all

print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
if [[ ${INPUT_EMPTYCOMMITS} == "true" ]]; then
git commit --allow-empty -m "${COMMIT_MESSAGE}"
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
git commit -m "${COMMIT_MESSAGE}" || skip
else
git commit -m "${COMMIT_MESSAGE}" || \
print_info "No changes detected, skipping deployment" && \
exit 0
git commit --allow-empty -m "${COMMIT_MESSAGE}"
fi

git push origin "${remote_branch}"
Expand Down

0 comments on commit 8f168fe

Please sign in to comment.