diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 807e590c..8f62d065 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,4 +57,4 @@ jobs: SOURCE: "public/" REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_USER: ${{ secrets.REMOTE_USER }} - TARGET: "/home/${{ secrets.REMOTE_USER }}/jorjafox.net/" + TARGET: "/home/${{ secrets.REMOTE_USER }}/${{ secrets.REMOTE_HOST }}/" diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 00000000..dff97ecb --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,57 @@ +name: 'Generate and deploy Staging' + +on: + push: + branches: [ trunk ] + +jobs: + deploy-website: + runs-on: ubuntu-latest + steps: + - name: Do a git checkout including submodules + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install SSH Key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SERVER_SSH_KEY }} + known_hosts: unnecessary + + - name: Adding Known Hosts + run: ssh-keyscan -H ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Setup Node and Install + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install Dependencies + run: npm install && npm run mod:update + + - name: Make Resources Folder locally + run: mkdir resources + + - name: Download resources from server + run: rsync -rlgoDzvc -i ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:/home/${{ secrets.REMOTE_USER }}/${{ secrets.HUGO_RESOURCES_URL }}/ resources/ + + - name: Build site + run: npm run build + + - name: Deploy to Server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} + ARGS: "-rlgoDzvc -i" + SOURCE: "public/" + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: "/home/${{ secrets.REMOTE_USER }}/${{ secrets.STAGING_SERVER }}/"