Use actions/upload-artifact and download-artifact for cross-job file sharing
Build and deploy Hugo site / build (push) Successful in 37s
Build and deploy Hugo site / deploy (push) Failing after 38s

This commit is contained in:
YaoLei
2026-07-06 14:06:53 +08:00
parent accdf7c3d3
commit 59cc2f1a62
+12 -16
View File
@@ -6,7 +6,6 @@ jobs:
runs-on: act_runner1
container:
image: 192.168.254.5:5000/hugo:v0.163.3
options: -v /tmp:/tmp
steps:
- name: Create Hugo site
run: |
@@ -29,32 +28,29 @@ jobs:
set -e
hugo --minify
- name: Copy public directory to shared location
run: |
set -e
mkdir -p /tmp/shared/public
cp -r /tmp/hugo-site/public/* /tmp/shared/public/
- name: Show generated files
run: |
echo "Shared public directory contents:"
ls -la /tmp/shared/public || true
- name: Upload public directory
uses: actions/upload-artifact@v3
with:
name: public
path: /tmp/hugo-site/public
deploy:
runs-on: act_runner1
needs: build
container:
image: alpine:latest
options: -v /tmp:/tmp
steps:
- name: Download public directory
uses: actions/download-artifact@v3
with:
name: public
path: ./public
- name: Deploy via rsync
run: |
set -e
apk add --no-cache rsync openssh-client
# Setup SSH key for rsync
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H 192.168.254.5 >> ~/.ssh/known_hosts
# Deploy using rsync
rsync -avz --delete /tmp/shared/public/ root@192.168.254.5:/opt/1panel/www/sites/www.learngaming.top/index/
rsync -avz --delete ./public/ root@192.168.254.5:/opt/1panel/www/sites/www.learngaming.top/index/