Update website workflow article #217
This file contains 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: CD | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
Build: | |
runs-on: | |
- self-hosted | |
- CI-CD | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.BUILD_WEBSITE_TOKEN }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Init theme submodule | |
run: git submodule update --init | |
- name: Copy custom CSS in theme | |
run: cp custom.css themes/anatole/assets/css/custom.css | |
- name: Build website | |
run: rm -rf public && hugo | |
- name: Commit automated build | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
if [ "$(git status --porcelain public)" ]; then | |
git add public | |
git commit -m "Automated build" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
Deploy: | |
needs: Build | |
runs-on: | |
- self-hosted | |
- CI-CD | |
steps: | |
- name: Deploy website | |
run: | | |
if [ "$(git rev-parse --abbrev-ref HEAD)" == "dev" ]; then | |
/opt/github-runner/antiz.fr/deploy_website.sh dev | |
elif [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]; then | |
/opt/github-runner/antiz.fr/deploy_website.sh prod | |
else | |
echo "Invalid branch, nothing to deploy" | |
exit 1 | |
fi |