Compare commits

...

8 Commits

Author SHA1 Message Date
dependabot-preview[bot]
45b43ab257 deps: bump alpine from 3.11.2 to 3.11.3
Bumps alpine from 3.11.2 to 3.11.3.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-20 09:20:42 +00:00
Shohei Ueda
0b9b068db1 chore: Fix typo 2020-01-19 00:07:44 +09:00
Shohei Ueda
9ba947f545 feat: Add tagName and tagMessage options (#78)
* feat: Add tagName and tagMessage options
* feat: Add print_info for tag options
* feat: Add tagOverwrite option
* docs: Add new section about Git tag options

Close #76
2020-01-18 12:55:18 +09:00
Shohei Ueda
ebe79a723c chore: Update LICENSE year 2020-01-16 17:42:57 +09:00
VladimirLogachev
c77e021886 docs: Add elm example workflow (#65)
* Add elm section to README.md
2020-01-12 21:56:01 +09:00
peaceiris
37729f1bb3 docs: Use head_commit instead of commits[0] 2020-01-07 00:20:56 +09:00
Shohei Ueda
76351d52b8 feat: Add commitMessage option (#75)
* feat: Add commitMessage option
* docs: Add custom commit message option

Close #74
cf. #72 and #73
2020-01-06 23:46:48 +09:00
Shohei Ueda
fd02997068 fix: link to commit hash for external deployment (#73)
cf. #72
2020-01-06 23:10:35 +09:00
5 changed files with 165 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
FROM alpine:3.11.2
FROM alpine:3.11.3
RUN apk add --no-cache \
bash \

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Shohei Ueda (peaceiris)
Copyright (c) 2020 Shohei Ueda (peaceiris)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

118
README.md
View File

@@ -72,6 +72,8 @@ Do you want to skip the docker build step? OK, the script mode is available.
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
- [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
- [Tips and FAQ](#tips-and-faq)
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
@@ -85,6 +87,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
- [⭐️ Static Site Generators with Python](#%EF%B8%8F-static-site-generators-with-python)
- [⭐️ mdBook (Rust)](#%EF%B8%8F-mdbook-rust)
- [⭐️ Flutter Web](#%EF%B8%8F-flutter-web)
- [⭐️ Elm](#%EF%B8%8F-elm)
- [License](#license)
- [About the author](#about-the-author)
@@ -329,6 +332,79 @@ A commit is always created with the same user.
useremail: "iris@peaceiris.com"
```
### ⭐️ Set custom commit message
Set custom commit message.
When we create a commit with a message `docs: Update some post`, a deployment commit will be generated with a message `docs: Update some post ${GITHUB_SHA}`.
```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
with:
commitMessage: ${{ github.event.head_commit.message }}
```
### ⭐️ Create Git tag
Here is an example workflow.
```yaml
name: github pages
on:
push:
branches:
- master
tags:
- 'v*.*.*'
jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Some build
- name: Prepare tag
id: prepare_tag
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${GITHUB_REF##refs/tags/}"
echo "::set-output name=tag_name::${TAG_NAME}"
echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}"
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
with:
tagName: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
tagMessage: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
```
Commands on a local machine.
```console
$ # On the master branch
$ git tag -a "v1.2.3" -m "Release v1.2.3"
$ git push origin "v1.2.3"
$ # After deployment
$ git fetch origin
$ git tag
deploy-v1.2.3 # Tag on the gh-pages branch
v1.2.3 # Tag on the master branch
```
We can set `tagOverwrite` option to `true` for overwriting a tag.
### ⭐️ Script mode
From `v2.5.0`, we can run this action as a shell script.
@@ -768,6 +844,48 @@ jobs:
PUBLISH_DIR: ./build/web
```
### ⭐️ Elm
An exapmle workflow for [Elm] with [justgook/setup-elm].
[Elm]: https://elm-lang.org
[justgook/setup-elm]: https://github.com/justgook/setup-elm
```yaml
name: github pages
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm
uses: justgook/setup-elm@v1
- name: Make
run: elm make --optimize src/Main.elm
- name: Move files
run: |
mkdir ./public
mv ./index.html ./public/
# If you have non-minimal setup with some assets and separate html/js files,
# provide --output=<output-file> option for `elm make` and remove this step
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
```
## License
- [MIT License - peaceiris/actions-gh-pages]

View File

@@ -26,3 +26,16 @@ inputs:
useremail:
description: 'Set Git user.email'
required: false
commitMessage:
description: 'Set custom commit message'
required: false
tagName:
description: 'Set tag name'
required: false
tagMessage:
description: 'Set tag message'
required: false
tagOverwrite:
description: 'Enable overwriting tag'
required: false
default: false

View File

@@ -53,7 +53,7 @@ elif [ -n "${GITHUB_TOKEN}" ]; then
print_error "GITHUB_TOKEN works only private repo, See #9"
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
print_error "can not use GITHUB_TOKEN to deploy to a external repository"
print_error "can not use GITHUB_TOKEN to deploy to an external repository"
exit 1
fi
@@ -117,7 +117,19 @@ git remote add origin "${remote_repo}"
git add --all
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
if [ -n "${INPUT_COMMITMESSAGE}" ]; then
BASE_COMMIT_MESSAGE="${INPUT_COMMITMESSAGE}"
else
BASE_COMMIT_MESSAGE="Automated deployment: $(date -u)"
fi
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
else
COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_SHA}"
fi
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
git commit -m "${COMMIT_MESSAGE}" || skip
else
@@ -130,4 +142,22 @@ else
git push origin "${remote_branch}"
fi
if [[ -n "${INPUT_TAGNAME}" ]]; then
print_info "Tag name: ${INPUT_TAGNAME}"
print_info "Tag message: ${INPUT_TAGMESSAGE}"
print_info "Tag overwrite: ${INPUT_TAGOVERWRITE}"
if [[ -n "${INPUT_TAGMESSAGE}" ]]; then
GIT_TAG_MESSAGE="${INPUT_TAGMESSAGE}"
else
GIT_TAG_MESSAGE="Deployment ${INPUT_TAGNAME}"
fi
if [[ "${INPUT_TAGOVERWRITE}" == "true" ]]; then
GIT_TAG_OPTION="--force"
else
GIT_TAG_OPTION=""
fi
git tag "${GIT_TAG_OPTION}" -a "${INPUT_TAGNAME}" -m "${GIT_TAG_MESSAGE}"
git push "${GIT_TAG_OPTION}" origin "${INPUT_TAGNAME}"
fi
print_info "${GITHUB_SHA} was successfully deployed"