diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9eeb14b0..5a011f69 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,6 @@ -name: Deploy +name: Deploy (Production) -on: +on: workflow_dispatch: inputs: hostname: @@ -10,30 +10,9 @@ on: default: antville.org jobs: - stage: + deploy: runs-on: antville - environment: - name: production - url: ${{ inputs.hostname }} - steps: - - uses: actions/checkout@v4 - - - name: Build with Gradle - run: ./gradlew installDist - - - name: Copy build files to server - run: | - rsync ./build/install/helma/ ${{ inputs.hostname }}:./ \ - --verbose --archive --delete --compress \ - --filter '+ /bin' \ - --filter '+ /extras' \ - --filter '+ /launcher.jar' \ - --filter '- /lib/ext' \ - --filter '+ /lib' \ - --filter '+ /modules' \ - --filter '- /*' - - - name: Restart Helma - run: ssh ${{ inputs.hostname }} restart + - name: Copy files to production server + run: ssh ${{ inputs.hostname }} deploy-helma diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml new file mode 100644 index 00000000..94e991cf --- /dev/null +++ b/.github/workflows/stage.yml @@ -0,0 +1,39 @@ +name: Deploy (Staging) + +on: + workflow_dispatch: + inputs: + hostname: + description: Hostname + type: string + required: true + default: antville.org + +jobs: + stage: + runs-on: antville + + environment: + name: stage + url: ${{ inputs.hostname }} + + steps: + - uses: actions/checkout@v4 + + - name: Build with Gradle + run: ./gradlew installDist + + - name: Copy build files to server + run: | + rsync ./build/install/helma/ ${{ inputs.hostname }}:./ \ + --verbose --archive --delete --compress \ + --filter '+ /bin' \ + --filter '+ /extras' \ + --filter '+ /launcher.jar' \ + --filter '- /lib/ext' \ + --filter '+ /lib' \ + --filter '+ /modules' \ + --filter '- /*' + + - name: Restart Helma + run: ssh ${{ inputs.hostname }} restart diff --git a/src/dist/extras/deploy.sh b/src/dist/extras/deploy.sh index 869cf945..6ebd6bf2 100755 --- a/src/dist/extras/deploy.sh +++ b/src/dist/extras/deploy.sh @@ -3,11 +3,50 @@ # Use this script as forced command of an authorized SSH key: # command="/home/helma/extras/deploy.sh" ssh-ed25519 AAAAC3NzaC… +# Define HELMA_HOST and ANTVILLE_HOST in this file +# shellcheck source=/dev/null +. "$HOME"/deploy.env + case "$SSH_ORIGINAL_COMMAND" in ping) echo pong ;; + deploy-helma) + rsync ./ "$HELMA_HOST":./ \ + --archive --compress --delete --verbose \ + --filter '+ /bin' \ + --filter '+ /extras' \ + --filter '+ /launcher.jar' \ + --filter '- /lib/ext' \ + --filter '+ /lib' \ + --filter '+ /modules' \ + --filter '- /*' + printf 'Restarting Helma on HELMA_host… ' + ssh "$HELMA_HOST" sudo /bin/systemctl restart helma + ;; + + deploy-antville) + rsync ./apps/antville/ "$ANTVILLE_HOST":./apps/antville/ \ + --archive --compress --delete --verbose \ + --filter '+ /claustra' \ + --filter '+ /code' \ + --filter '+ /compat' \ + --filter '+ /i18n' \ + --filter '+ /lib' \ + --filter '- /*' + rsync ./apps/antville/static/helma/ "$ANTVILLE_HOST":./apps/antville/static/helma/ \ + --archive --compress --verbose \ + --filter '+ /fonts' \ + --filter '+ /formica.html' \ + --filter '+ /img' \ + --filter '+ /scripts' \ + --filter '+ /styles' \ + --filter '- /*' + printf 'Restarting Helma on ANTVILLE_host… ' + ssh "$ANTVILLE_HOST" sudo /bin/systemctl restart helma + ;; + restart) printf 'Restarting Helma… ' sudo /bin/systemctl restart helma