Workflow - Github #11
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: Zola Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # Install dependencies | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y curl unzip rsync git | |
| # Install Zola | |
| - name: Install Zola | |
| run: | | |
| curl -s -L https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-x86_64-unknown-linux-musl.tar.gz \ | |
| | sudo tar xvzf - -C /usr/local/bin | |
| zola --version | |
| # Build site | |
| - name: Build site | |
| run: zola build --output-dir publish_tmp --force | |
| # Deploy to submodule repo | |
| - name: Deploy to public submodule | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| TIMESTAMP=$(date '+%Y-%m-%d %I:%M:%S %p') | |
| rsync -av --delete --exclude='.git' --exclude="CNAME" publish_tmp/ public/ | |
| cd public | |
| git config --global user.name "tr1xem" | |
| git config --global user.email "[email protected]" | |
| git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/tr1xem/tr1xem.github.io.git | |
| git add . | |
| git commit -m "Automated Deploy: $TIMESTAMP" || echo "No changes to deploy." | |
| git push origin HEAD:main | |
| cd .. | |
| # Commit source repo changes if any | |
| - name: Commit source repo | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| TIMESTAMP=$(date '+%Y-%m-%d %I:%M:%S %p') | |
| git add . | |
| git commit -m "Automated Commit: $TIMESTAMP" || echo "No source changes." | |
| git push https://${GH_TOKEN}@github.com/tr1xem/tr1xem.git main |