Skip to content

Commit

Permalink
feat: to support gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
walterhu2020 committed Mar 25, 2021
1 parent 08f5143 commit 01c8e94
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:12-buster-slim

LABEL version="1.0.3"
LABEL repository="https://github.com/sma11black/hexo-action"
LABEL homepage="https://sma11black.github.io"
LABEL maintainer="sma11black <smallblack@outlook.com>"
LABEL version="1.0.0"
LABEL repository="https://github.com/alterhu2020/hexo-gulp-action"
LABEL homepage="https://seniortesting.club"
LABEL maintainer="alterhu2020 <alterhu2020@gmail.com>"

COPY entrypoint.sh /entrypoint.sh
COPY sync_deploy_history.js /sync_deploy_history.js
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# GitHub Action - Hexo CI/CD 🌱
# GitHub Action - Hexo CI/CD with Gulp Support 🌱

<a href="https://github.com/marketplace/actions/hexo-action"><img alt="View Action" src="https://img.shields.io/badge/action-marketplace-blue.svg?logo=github&color=orange"></a>
<a href="https://github.com/marketplace/actions/hexo-gulp-action"><img alt="View Action" src="https://img.shields.io/badge/action-marketplace-blue.svg?logo=github&color=orange"></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green.svg?logo=github"></a>

This Github Action automating hexo deployment workflow, to allow you to leverage GitHub Actions to publish your hexo site on Github Pages.
NOTE: Fork from: <https://github.com/sma11black/hexo-action>

This Github Action automating hexo deployment workflow, to allow you to leverage GitHub Actions to publish your hexo site on Github Pages and Gulp Support to minimal Hexo website.

## 🍑Usage
### 🍄Pre-requisites
#### Step 1: Setup `Deploy keys` and `Secrets`

The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the [example workflow](#🍌example-workflow---hexo-deploy) below. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repositories `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsenv).

**🥕How to add your ssh key pair?**

1. Run the following terminal command, replacing the email with one connected to your GitHub account.
```sh
$ ssh-keygen -t rsa -C "[email protected]"
Expand All @@ -19,9 +23,11 @@ $ ssh-keygen -t rsa -C "[email protected]"
3. In *hexo source code* repo: Add the contents of the private key to the `Settings > Secrets` menu as DEPLOY_KEY.

#### Step 2: Configure github workflows

Create a workflow `.yml` file in your `.github/workflows` directory. An [example workflow](#🍌example-workflow---hexo-deploy) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).

### 🍆Inputs

For more information on these inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

| Key | Required | Description | Default |
Expand All @@ -36,15 +42,18 @@ For more information on these inputs, see the [API Documentation](https://develo
- [1] 41898282 is the user ID for `github-actions[bot]`. Ref [Github API](https://api.github.com/users/github-actions[bot]/events/public).

**Tips**:

- `user_name` and `user_email`: Github Actions bot is just a bot account to perform these operations so that users would know that they were triggered by automation. There is an known issue if you use this bot account. In your GitHub Pages repository, if you want to filter commits by author, it will return a wrong result: `No commits found for "github-actions[bot]"`. You can avoid such error by using your github account instead of default bot account.
- `commit_msg`: For [Hexo official](https://hexo.io/docs/one-command-deployment.html#Git), the commit message is default to `Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }}`. But for users who actually need to keep commit history, they may not need such one. So the recommended setting is `${{ github.event.head_commit.message }}` so that you can transfer commit messages to the GitHub Pages repository directly. If you prefer the default commit message, it is unnecessary to set in your workflow file or set `commit_msg` to `default`. For users who don’t want any commit history, you can set `commit_msg` to `none`. Since `default` and `none` are reserved words for control, you cannot set the commit message to these two words alone.

### 🥒Outputs

For more information on these outputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#response-4) for an example of what these outputs look like

- `notify`: Deploy complate notification.

### 🍌Example workflow - hexo deploy

On every `push` to this repo, generate hexo sites and publish on `username.github.io` repo.

```yaml
Expand Down Expand Up @@ -78,7 +87,7 @@ jobs:
# Deploy hexo blog website.
- name: Deploy
id: deploy
uses: sma11black/[email protected].3
uses: alterhu2020/hexo-gulp-[email protected].0
with:
deploy_key: ${{ secrets.DEPLOY_KEY }}
user_name: your github username # (or delete this input setting to use bot account)
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Hexo Action'
description: 'Hexo CI/CD action for automating deployment.'
author: 'sma11black'
name: 'Hexo Gulp Action'
description: 'Hexo CI/CD action for automating deployment with Gulp Support.'
author: 'alterhu2020'
inputs:
user_name:
description: 'Github user name'
Expand Down
16 changes: 13 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ git config --global user.email "$INPUT_USER_EMAIL"
# install hexo env
npm install hexo-cli -g
npm install hexo-deployer-git --save
npm install gulp-cli -g

# deployment
if [ "$INPUT_COMMIT_MSG" = "none" ]
then
hexo g -d
hexo clean
hexo generate
gulp
hexo deploy
elif [ "$INPUT_COMMIT_MSG" = "" ] || [ "$INPUT_COMMIT_MSG" = "default" ]
then
# pull original publish repo
NODE_PATH=$NODE_PATH:$(pwd)/node_modules node /sync_deploy_history.js
hexo g -d
hexo clean
hexo generate
gulp
hexo deploy
else
NODE_PATH=$NODE_PATH:$(pwd)/node_modules node /sync_deploy_history.js
hexo g -d -m "$INPUT_COMMIT_MSG"
hexo clean
hexo generate
gulp
hexo deploy -m "$INPUT_COMMIT_MSG"
fi

echo ::set-output name=notify::"Deploy complate."

0 comments on commit 01c8e94

Please sign in to comment.