refactor ci
This commit is contained in:
parent
cc0a34b23b
commit
e5e8cb1d9a
|
@ -1,22 +1,18 @@
|
|||
name: Build & Deploy
|
||||
on: [push, workflow_dispatch]
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.name ${{ secrets.GIT_USERNAME }}
|
||||
git config --global user.email ${{ secrets.GIT_EMAIL }}
|
||||
git config --global init.defaultBranch main
|
||||
# - name: Configure Git
|
||||
# run: |
|
||||
# git config --global user.name ${{ secrets.GIT_USERNAME }}
|
||||
# git config --global user.email ${{ secrets.GIT_EMAIL }}
|
||||
# git config --global init.defaultBranch main
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true # Checkout private submodules(themes or something else).
|
||||
- name: Setup SSH
|
||||
uses: https://github.com/webfactory/ssh-agent@v0.7.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
- name: Setup Hugo
|
||||
uses: https://github.com/peaceiris/actions-hugo@v2
|
||||
with:
|
||||
|
@ -27,7 +23,44 @@ jobs:
|
|||
- name: Add known host
|
||||
run:
|
||||
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
|
||||
- name: Publish
|
||||
run: |
|
||||
apt update && apt install rsync -y
|
||||
rsync -av --delete -e "ssh -p ${{ secrets.SSH_PORT }}" public/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ secrets.WEB_ROOT }}
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: public
|
||||
path: public/
|
||||
|
||||
deploy-to-remote:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get build artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: public
|
||||
path: public/
|
||||
- name: Setup SSH
|
||||
uses: https://github.com/webfactory/ssh-agent@v0.7.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
- name: Publish to remote
|
||||
run: |
|
||||
apt update && apt install rsync -y
|
||||
rsync -av --delete -e "ssh -p ${{ secrets.SSH_PORT }}" public/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ secrets.WEB_ROOT }}
|
||||
|
||||
deploy-to-cloudflare:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Get build artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: public
|
||||
path: public/
|
||||
- name: Publish to Cloudflare
|
||||
uses: cloudflare/wrangler-action@2.0.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
env:
|
||||
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
|
|
Loading…
Reference in a new issue