From 9635422253bca0b712de3ac6c9826420db1ba383 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Wed, 14 Jul 2021 05:50:15 +0000 Subject: [PATCH 1/3] Update README.md --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/README.md b/README.md index 76f74cc..8eedb61 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,58 @@ deploy to s3: - aws s3 rm s3://$S3_BUCKET --recursive - aws s3 cp public s3://$S3_BUCKET --recursive ``` +### GitHub Action +In case you want to deploy your website via GitHub Action, here are some of the code you can use: +```yaml +# workflow name +name: Hexo Blog CI + +# master branch on push, auto run +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # check it to your workflow can access it + # from: https://github.com/actions/checkout + - name: Checkout Repository master branch + uses: actions/checkout@master + + # from: https://github.com/actions/setup-node + - name: Setup Node.js 10.x + uses: actions/setup-node@master + with: + node-version: "10.x" + + - name: Setup Hexo Dependencies + run: | + npm install hexo-cli -g + npm install + + - name: Setup Deploy Private Key + env: + HEXO_DEPLOY_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_PRIVATE_KEY }} + run: | + mkdir -p ~/.ssh/ + echo "$HEXO_DEPLOY_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + + - name: Setup Git Infomation + run: | + git config --global user.name 'ๅๅญ—' + git config --global user.email '้‚ฎไปถ' + - name: Deploy Hexo + run: | + hexo clean + hexo generate + hexo deploy +``` ### Testing our builds before pushing content to the `master` branch What if we want to test our builds in another branch before afecting `master`? From 2ecd617bdab81b3bc3b99666da298d7286c9e3a6 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Wed, 14 Jul 2021 06:04:59 +0000 Subject: [PATCH 2/3] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 8eedb61..3237f43 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,28 @@ jobs: hexo deploy ``` +### GitHub Action with FTP +```yaml +on: push +name: ๐Ÿš€ Deploy website on push +jobs: + web-deploy: + name: ๐ŸŽ‰ Deploy + runs-on: ubuntu-latest + steps: + - name: ๐Ÿšš Get latest code + uses: actions/checkout@v2 + + - name: ๐Ÿ“‚ Sync files + uses: SamKirkland/FTP-Deploy-Action@4.1.0 + with: + server: ftp.samkirkland.com + username: myFtpUserName + password: ${{ secrets.ftp_password }} + port: 21 + server-dir: # Setting the server-directory +``` + ### Testing our builds before pushing content to the `master` branch What if we want to test our builds in another branch before afecting `master`? We'll just need to set a `test` job to do this for us: From 26cbdd9b4aaf3103ea6485cdbe53630c76e560f6 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Wed, 14 Jul 2021 06:18:09 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/README.md b/README.md index 3237f43..8d3866e 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,68 @@ jobs: server-dir: # Setting the server-directory ``` +### GitHub Action with Hexo and FTP +```yaml +# workflow name +name: Hexo Blog CI + +# master branch on push, auto run +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # check it to your workflow can access it + # from: https://github.com/actions/checkout + - name: Checkout Repository master branch + uses: actions/checkout@master + + # from: https://github.com/actions/setup-node + - name: Setup Node.js 10.x + uses: actions/setup-node@master + with: + node-version: "10.x" + + - name: Setup Hexo Dependencies + run: | + npm install hexo-cli -g + npm install + + - name: Setup Deploy Private Key + env: + HEXO_DEPLOY_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_PRIVATE_KEY }} + run: | + mkdir -p ~/.ssh/ + echo "$HEXO_DEPLOY_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + + - name: Setup Git Infomation + run: | + git config --global user.name 'ๅๅญ—' + git config --global user.email '้‚ฎไปถ' + + - name: Deploy Hexo + run: | + hexo clean + hexo generate + hexo deploy + + - name: ๐Ÿ“‚ Sync files + uses: SamKirkland/FTP-Deploy-Action@4.1.0 + with: + server: ftp.samkirkland.com + username: myFtpUserName + password: ${{ secrets.ftp_password }} + port: 21 + server-dir: # Setting the server-directory +``` + ### Testing our builds before pushing content to the `master` branch What if we want to test our builds in another branch before afecting `master`? We'll just need to set a `test` job to do this for us: