@@ -73,6 +73,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
7373 - [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
7474 - [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
7575 - [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
76+ - [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
7677 - [⭐️ Script mode](#%EF%B8%8F-script-mode)
7778- [Tips and FAQ](#tips-and-faq)
7879 - [⭐️ 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
347348 commitMessage: ${{ github.event.head_commit.message }}
348349` ` `
349350
351+ # ## ⭐️ Create Git tag
352+
353+ Here is an example workflow.
354+
355+ ` ` ` yaml
356+ name: github pages
357+
358+ on:
359+ push:
360+ branches:
361+ - master
362+ tags:
363+ - 'v*.*.*'
364+
365+ jobs:
366+ build-deploy:
367+ runs-on: ubuntu-18.04
368+ steps:
369+ - uses: actions/checkout@v2
370+
371+ - name: Some build
372+
373+ - name: Prepare tag
374+ id: prepare_tag
375+ if: startsWith(github.ref, 'refs/tags/')
376+ run: |
377+ TAG_NAME="${GITHUB_REF##refs/tags/}"
378+ echo "::set-output name=tag_name::${TAG_NAME}"
379+ echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}"
380+
381+ - name: Deploy
382+ uses: peaceiris/actions-gh-pages@v2
383+ env:
384+ ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
385+ PUBLISH_BRANCH: gh-pages
386+ PUBLISH_DIR: ./public
387+ with:
388+ tagName: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
389+ tagMessage: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
390+ ` ` `
391+
392+ Commands on a local machine.
393+
394+ ` ` ` console
395+ $ # On the master branch
396+ $ git tag -a "v1.2.3" -m "Release v1.2.3"
397+ $ git push origin "v1.2.3"
398+
399+ $ # After deployment
400+ $ git fetch origin
401+ $ git tag
402+ deploy-v1.2.3 # Tag on the gh-pages branch
403+ v1.2.3 # Tag on the master branch
404+ ` ` `
405+
406+ We can set `tagOverwrite` option to `true` for overwriting a tag.
407+
350408# ## ⭐️ Script mode
351409
352410From `v2.5.0`, we can run this action as a shell script.
0 commit comments