Build Website and Push #860
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: Build Website and Push | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '55 15 * * *' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Set Up timezone | |
| uses: szenius/set-timezone@v2.0 | |
| with: | |
| timezoneLinux: "Asia/Shanghai" | |
| - name: Checkout course | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: 'XS-MLVP/course' | |
| token: ${{ secrets.COMMIT_KEY }} | |
| path: 'course' | |
| - name: Checkout doc-xs-ov-00-bpu | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: 'XS-MLVP/doc-xs-ov-00-bpu' | |
| token: ${{ secrets.COMMIT_KEY }} | |
| path: 'doc-xs-ov-00-bpu' | |
| - name: Checkout UnityChipForXiangShan | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: 'XS-MLVP/UnityChipForXiangShan' | |
| token: ${{ secrets.COMMIT_KEY }} | |
| path: 'UnityChipForXiangShan' | |
| - name: Checkout mlvp-portal | |
| uses: actions/checkout@v2 | |
| with: | |
| path: 'mlvp-portal' | |
| - name: Checkout xs-mlvp.github.io | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: 'XS-MLVP/xs-mlvp.github.io' | |
| token: ${{ secrets.COMMIT_KEY }} | |
| path: 'xs-mlvp.github.io' | |
| - name: Check if there are commits today | |
| id: check-commits | |
| run: | | |
| skip=true | |
| for repo in course doc-xs-ov-00-bpu mlvp-portal; do | |
| cd $repo | |
| if [ "$(git log --since='1 day ago' --oneline | wc -l)" -ne "0" ]; then | |
| skip=false | |
| cd .. | |
| break | |
| fi | |
| cd .. | |
| done | |
| cd UnityChipForXiangShan | |
| DIRECTORY="documents" | |
| if [ "$(git log -1 --format=%ct -- $DIRECTORY)" -ne "0" ]; then | |
| echo "New commits found in $DIRECTORY" | |
| skip=false | |
| else | |
| echo "No new commits in $DIRECTORY" | |
| fi | |
| cd .. | |
| cd xs-mlvp.github.io | |
| DIRECTORY="UnityChipForXiangShan/data/reports" | |
| if [ "$(git log -1 --format=%ct -- $DIRECTORY)" -ne "0" ]; then | |
| echo "New commits found in $DIRECTORY" | |
| skip=false | |
| fi | |
| cd .. | |
| echo "SKIP=$skip" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Run make commands | |
| if: env.SKIP == 'false' | |
| run: | | |
| cd /home/runner/work/mlvp-portal/mlvp-portal/course | |
| make init | |
| cd /home/runner/work/mlvp-portal/mlvp-portal/doc-xs-ov-00-bpu | |
| make init | |
| cd /home/runner/work/mlvp-portal/mlvp-portal/UnityChipForXiangShan/documents | |
| ln -s /home/runner/work/mlvp-portal/mlvp-portal/xs-mlvp.github.io/UnityChipForXiangShan/data/reports static/data/reports | |
| find /home/runner/work/mlvp-portal/mlvp-portal/xs-mlvp.github.io/UnityChipForXiangShan/data/reports -maxdepth 1 -mindepth 1 -type d -print0 | sort -zr | tail -zn +2 | xargs -0 rm -rf | |
| make init | |
| cd /home/runner/work/mlvp-portal/mlvp-portal/mlvp-portal | |
| npm install -D autoprefixer | |
| npm install -D postcss-cli | |
| npm install -D postcss | |
| make build | |
| - name: Configure git and sync | |
| if: env.SKIP == 'false' | |
| run: | | |
| cd /home/runner/work/mlvp-portal/mlvp-portal/xs-mlvp.github.io | |
| git config user.name "github-actions[bot]" | |
| git config user.email "22570332+github-actions[bot]@users.noreply.github.com" | |
| make sync |