Deploy Jekyll site to CPanel #99
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: Deploy Jekyll site to CPanel | |
| on: | |
| push: | |
| branches: ["main"] | |
| schedule: | |
| - cron: '15 5 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| artifact_id: ${{ steps.upload.outputs.artifact_id }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| cache-version: 0 | |
| - name: Install NPM Packages | |
| run: npm install | |
| - name: Execute PostCSS | |
| run: npx postcss assets/style.css -o dist.css | |
| - name: Version and Install `dist.css` | |
| run: | | |
| export CSS_DIST_HASH=$( md5sum dist.css | cut -c 1-8 ); | |
| rm assets/style.css; | |
| rm assets/uac/*.css; | |
| mv dist.css assets/dist_$CSS_DIST_HASH.css; | |
| sed "s~/assets/style\.css~/assets/dist_$CSS_DIST_HASH\.css~" -i _includes/styles.html | |
| - name: Build with Jekyll | |
| run: bundle exec jekyll build --future | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Upload Artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| id: upload | |
| # Deployment job | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| artifact-ids: ${{ needs.build.outputs.artifact_id }} | |
| - name: Extract artifact | |
| run: | | |
| mkdir _site; | |
| tar -xvf github-pages/artifact.tar -C _site | |
| - name: Sync files | |
| uses: SamKirkland/[email protected] | |
| with: | |
| server: ${{ vars.CPANEL_FTP_HOST }} | |
| username: ${{ vars.CPANEL_FTP_USERNAME }} | |
| password: ${{ secrets.CPANEL_FTP_PASSWORD }} | |
| protocol: ftps | |
| local-dir: _site/ |