Skip to content

Commit

Permalink
Use SFTP instead of direct updating
Browse files Browse the repository at this point in the history
  • Loading branch information
29cmb committed Nov 29, 2024
1 parent e41e28c commit 2b15de3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: 'Upload Resource Pack'
on:
workflow_dispatch:
inputs:
Expand All @@ -22,17 +23,34 @@ jobs:
- name: Install SSH client and sshpass
run: sudo apt-get update && sudo apt-get install -y openssh-client sshpass

- name: SSH into server and update server.properties
- name: Download server.properties
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_DOMAIN: ${{ secrets.SSH_DOMAIN }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
run: |
sshpass -p $SSH_PASSWORD sftp -o StrictHostKeyChecking=no -P $SSH_PORT $SSH_USERNAME@$SSH_DOMAIN << 'EOF'
get /path/to/server.properties server.properties
bye
EOF
- name: Update server.properties
env:
RESOURCE_PACK_URL: ${{ github.event.inputs.resource_pack_url }}
RESOURCE_PACK_HASH: ${{ github.event.inputs.resource_pack_hash }}
run: |
sshpass -p $SSH_PASSWORD ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$SSH_DOMAIN -p $SSH_PORT << 'EOF'
sed -i 's|^resource-pack=.*|resource-pack=${RESOURCE_PACK_URL}|' server.properties
sed -i 's|^resource-pack-sha1=.*|resource-pack-sha1=${RESOURCE_PACK_HASH}|' server.properties
exit
- name: Upload server.properties
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_DOMAIN: ${{ secrets.SSH_DOMAIN }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
run: |
sshpass -p $SSH_PASSWORD sftp -o StrictHostKeyChecking=no -P $SSH_PORT $SSH_USERNAME@$SSH_DOMAIN << 'EOF'
put server.properties /path/to/server.properties
bye
EOF

0 comments on commit 2b15de3

Please sign in to comment.