mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-14 14:16:00 +08:00
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
This commit is contained in:
parent
ebe79a723c
commit
9ba947f545
58
README.md
58
README.md
@ -73,6 +73,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
|
|||||||
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
|
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
|
||||||
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
|
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
|
||||||
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
|
- [⭐️ 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)
|
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
|
||||||
- [Tips and FAQ](#tips-and-faq)
|
- [Tips and FAQ](#tips-and-faq)
|
||||||
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
|
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
|
||||||
@ -347,6 +348,63 @@ When we create a commit with a message `docs: Update some post`, a deployment co
|
|||||||
commitMessage: ${{ github.event.head_commit.message }}
|
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
|
### ⭐️ Script mode
|
||||||
|
|
||||||
From `v2.5.0`, we can run this action as a shell script.
|
From `v2.5.0`, we can run this action as a shell script.
|
||||||
|
10
action.yml
10
action.yml
@ -29,3 +29,13 @@ inputs:
|
|||||||
commitMessage:
|
commitMessage:
|
||||||
description: 'Set custom commit message'
|
description: 'Set custom commit message'
|
||||||
required: false
|
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
|
||||||
|
@ -142,4 +142,22 @@ else
|
|||||||
git push origin "${remote_branch}"
|
git push origin "${remote_branch}"
|
||||||
fi
|
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"
|
print_info "${GITHUB_SHA} was successfully deployed"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user