Skip to content

Commit

Permalink
feat: Add emptyCommits option (#22)
Browse files Browse the repository at this point in the history
* feat: Add emptyCommits option (@kingofzeal)
* docs: Update README about emptyCommits option (@kingofzeal)
* gha: Update trigger of docker image ci workflow (@peaceiris)

Close #21
  • Loading branch information
kingofzeal authored and peaceiris committed Sep 14, 2019
1 parent dea149a commit 241ef9f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/docker-image-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: docker image ci

on:
push:
branches:
- master
- 'release-v*'
on: push

jobs:
test:
Expand All @@ -20,16 +16,6 @@ jobs:
docker build . --file Dockerfile --tag ${DOCKER_IMAGE} ||
(echo -e "\e[31m[${GITHUB_WORKFLOW}] failed to build\e[m" && exit 1)
# - name: push latest image
# if: endsWith(github.ref, 'master')
# env:
# DOCKER_IMAGE: docker.pkg.github.com/${{ github.repository }}/action:latest
# PKG_GITHUB_TOKEN: ${{ secrets.PKG_GITHUB_TOKEN }}
# run: |
# echo ${PKG_GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin &&
# docker push ${DOCKER_IMAGE} &&
# docker logout

shellcheck:
runs-on: ubuntu-18.04
steps:
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Table of Contents
- [:star: Pull action image from Docker Hub](#star-pull-action-image-from-docker-hub)
- [:star: `PERSONAL_TOKEN`](#star-personal_token)
- [:star: `GITHUB_TOKEN`](#star-github_token)
- [:star: Suppressing empty commits](#star-suppressing-empty-commits)
- [Examples](#examples)
- [Static Site Generators with Node.js](#static-site-generators-with-nodejs)
- [Gatsby](#gatsby)
Expand Down Expand Up @@ -156,6 +157,25 @@ By pulling docker images, you can reduce the overall execution time of your work
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

#### :star: Suppressing empty commits

By default, a commit will always be generated and pushed to the `PUBLISH_BRANCH`, even if nothing changed. If you want to suppress this behavior, set the optional parameter `emptyCommits` to `false`. cf. [Issue #21]

[Issue #21]: https://github.com/peaceiris/actions-gh-pages/issues/21

For example:

```yaml
- name: deploy
uses: peaceiris/[email protected]
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
with:
emptyCommits: false
```



## Examples
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ runs:
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
emptyCommits:
description: 'If empty commits should be made to the publication branch'
required: false
default: 'true'
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote rm origin || true
git remote add origin "${remote_repo}"
git add --all
git commit --allow-empty -m "Automated deployment: $(date -u) ${GITHUB_SHA}"

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}"
else
git commit -m "${COMMIT_MESSAGE}" || \
print_info "No changes detected, skipping deployment" && \
exit 0
fi

git push origin "${remote_branch}"
print_info "${GITHUB_SHA} was successfully deployed"

0 comments on commit 241ef9f

Please sign in to comment.