wip #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: "ubuntu-22.04" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install PHP | |
| run: bash .github/scripts/install-php84.sh | |
| - name: Use Composer dependencies cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/composer | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Use npm dependencies cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: ${{ runner.os }}-npm- | |
| - name: Install dependencies | |
| run: | | |
| composer install --no-interaction --no-progress --optimize-autoloader --no-dev | |
| npm ci | |
| npm run build | |
| - name: Prepare Client | |
| run: | | |
| mv client watchtower | |
| rm watchtower/.gitignore | |
| mv watchtower/scripts/install.sh public/install.sh | |
| tar --create --gzip --file=public/watchtower-client.tar.gz watchtower/ | |
| - name: Compress deployment artifacts | |
| run: | | |
| tar --create --gzip \ | |
| --exclude="bootstrap/cache/*" \ | |
| --exclude="node_modules" \ | |
| --exclude="public/storage" \ | |
| --exclude="storage" \ | |
| --exclude="tests" \ | |
| --file ~/artifacts.tar.gz * .github | |
| - name: Upload deployment artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deployment-artifacts | |
| path: ~/artifacts.tar.gz | |
| retention-days: 1 | |
| deploy-main: | |
| needs: build | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: "ubuntu-22.04" | |
| steps: | |
| - name: Download deployment artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: deployment-artifacts | |
| - name: Deploy | |
| env: | |
| base_directory: "~/www/watchtower" | |
| ssh_user: "sjorso" | |
| ssh_host: "167.235.26.246" | |
| ssh_port: 22 | |
| private_ssh_key: "${{ secrets.PRIVATE_SSH_KEY }}" | |
| ssh_known_hosts: "${{ secrets.SSH_KNOWN_HOSTS }}" | |
| php_executable: "php8.4" | |
| run: tar -xf artifacts.tar.gz .github/deployment/prepare.sh -O | bash -se -- "$base_directory" "$ssh_user" "$ssh_host" "$ssh_port" "$private_ssh_key" "$ssh_known_hosts" "$php_executable" | |
| - name: Deploy to Platform | |
| env: | |
| private_ssh_key: "${{ secrets.PLATFORM_PRIVATE_SSH_KEY }}" | |
| ssh_known_hosts: "${{ secrets.PLATFORM_SSH_KNOWN_HOSTS }}" | |
| run: tar -xf artifacts.tar.gz .github/bundle-to-platform/prepare.sh -O | bash -se -- "$private_ssh_key" "$ssh_known_hosts" |