feat: #32941 trigger build and deploy for specific branch
move main logic to seperate file and create seperate dev and prod actions executed on develop and main branch respectiveley
This commit is contained in:
parent
0f6d9fcfdb
commit
539618d957
2 changed files with 69 additions and 67 deletions
|
|
@ -1,4 +1,4 @@
|
|||
name: Build and Deploy Hugo Site
|
||||
name: Build and Deploy Hugo Site to Production
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -8,77 +8,20 @@ on:
|
|||
|
||||
|
||||
env:
|
||||
SSH_USER: verua_info
|
||||
PROD_HOST: verua.swiss
|
||||
PROD_PATH: httpdocs
|
||||
DEV_HOST: verua.info
|
||||
DEV_PATH: preview/httpdocs
|
||||
SSH_USER: verua.swiss
|
||||
SSH_HOST: verua.swiss
|
||||
DEPLOY_PATH: httpdocs
|
||||
|
||||
jobs:
|
||||
buildAndDeploy:
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
runs-on: ubuntu-latest
|
||||
call-build-workflow:
|
||||
uses: ./.gitea/build-workflow.yaml
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
|
||||
- name: env-toml-file
|
||||
uses: SebRollen/toml-action@v1.2.0
|
||||
id: read_toml
|
||||
with:
|
||||
file: 'hugo.toml'
|
||||
field: 'params.environment'
|
||||
|
||||
- name: Echo environment
|
||||
run: echo "Environment is ${{ steps.read_toml.outputs.value }}"
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5.0.0
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Setup Project
|
||||
run: npm run project-setup
|
||||
|
||||
- name: Install npm dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Set up Hugo Extended
|
||||
uses: peaceiris/actions-hugo@v3.0.0
|
||||
with:
|
||||
hugo-version: '0.121.2'
|
||||
extended: true
|
||||
|
||||
- name: Build Hugo site
|
||||
run: hugo --minify
|
||||
|
||||
- name: Setup rsync
|
||||
run: apt-get update && apt-get install -y rsync
|
||||
|
||||
- name: Setup SSH Key
|
||||
uses: webfactory/ssh-agent@v0.5.3
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.VFO_SSH_KEY }}
|
||||
|
||||
- name: Deploy to Development
|
||||
if: steps.read_toml.outputs.value == 'development'
|
||||
run: |
|
||||
echo "Running steps for Development Environment"
|
||||
echo "host: $DEV_HOST path: $DEV_PATH"
|
||||
rsync -avz ./public/ ${{ secrets.SSH_USER }}@$DEV_HOST:$DEV_PATH
|
||||
env:
|
||||
RSYNC_RSH: 'ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no'
|
||||
|
||||
- name: Deploy to Production
|
||||
if: steps.read_toml.outputs.value == 'production'
|
||||
run: |
|
||||
echo "Running steps for Production Environment"
|
||||
rsync -avz --delete ./public/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/${{ secrets.PRODUCTION_PATH }}
|
||||
echo "host: $DEV_HOST path: $DEV_PATH"
|
||||
# rsync -avz --delete ./public/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/${{ secrets.PRODUCTION_PATH }}
|
||||
rsync -avz ./public/ $SSH_USER@$SSH_HOST:$DEPLOY_PATH
|
||||
env:
|
||||
RSYNC_RSH: 'ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no'
|
||||
|
|
|
|||
59
.gitea/workflows/build-workflow.yaml
Normal file
59
.gitea/workflows/build-workflow.yaml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
name: Build Hugo Site
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets: inherit
|
||||
|
||||
jobs:
|
||||
build-wrokflow:
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
|
||||
- name: env-toml-file
|
||||
uses: SebRollen/toml-action@v1.2.0
|
||||
id: read_toml
|
||||
with:
|
||||
file: 'hugo.toml'
|
||||
field: 'params.environment'
|
||||
|
||||
- name: Echo environment
|
||||
run: echo "Environment is ${{ steps.read_toml.outputs.value }}"
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5.0.0
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Setup Project
|
||||
run: npm run project-setup
|
||||
|
||||
- name: Install npm dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Set up Hugo Extended
|
||||
uses: peaceiris/actions-hugo@v3.0.0
|
||||
with:
|
||||
hugo-version: '0.121.2'
|
||||
extended: true
|
||||
|
||||
- name: Build Hugo site
|
||||
run: hugo --minify
|
||||
|
||||
- name: Setup rsync
|
||||
run: apt-get update && apt-get install -y rsync
|
||||
|
||||
- name: Setup SSH Key
|
||||
uses: webfactory/ssh-agent@v0.5.3
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.VFO_SSH_KEY }}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue