main.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: Build
  2. on:
  3. push:
  4. branches:
  5. - master
  6. schedule:
  7. - cron: '0 12 * * *'
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v4
  14. with:
  15. persist-credentials: false
  16. - uses: oven-sh/setup-bun@v1
  17. with:
  18. bun-version: canary
  19. - name: Get current date
  20. id: date
  21. run: |
  22. echo "date=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
  23. echo "year=$(date +'%Y')" >> $GITHUB_OUTPUT
  24. echo "month=$(date +'%m')" >> $GITHUB_OUTPUT
  25. echo "day=$(date +'%d')" >> $GITHUB_OUTPUT
  26. echo "hour=$(date +'%H')" >> $GITHUB_OUTPUT
  27. echo "minute=$(date +'%M')" >> $GITHUB_OUTPUT
  28. echo "second=$(date +'%S')" >> $GITHUB_OUTPUT
  29. - name: Cache cache.db
  30. uses: actions/cache@v4
  31. with:
  32. save-always: true
  33. path: |
  34. .cache
  35. key: ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }} ${{ steps.date.outputs.hour }}:${{ steps.date.outputs.minute }}:${{ steps.date.outputs.second }}
  36. # If source files changed but packages didn't, rebuild from a prior cache.
  37. restore-keys: |
  38. ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }} ${{ steps.date.outputs.hour }}:${{ steps.date.outputs.minute }}:
  39. ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }} ${{ steps.date.outputs.hour }}:
  40. ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}
  41. ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-
  42. ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-
  43. ${{ runner.os }}-v3-
  44. - run: bun install
  45. - run: bun run build
  46. - name: Pre-deploy check
  47. # If the public directory doesn't exist, the build should fail.
  48. # If the public directory is empty, the build should fail.
  49. run: |
  50. if [ ! -d public ]; then
  51. echo "public directory not found"
  52. exit 1
  53. fi
  54. if [ ! "$(ls -A public)" ]; then
  55. echo "public directory is empty"
  56. exit 1
  57. fi
  58. - name: Deploy
  59. uses: peaceiris/actions-gh-pages@v3
  60. with:
  61. personal_token: ${{ secrets.GIT_TOKEN }}
  62. user_name: ${{ secrets.GIT_USER }}
  63. user_email: ${{ secrets.GIT_EMAIL }}
  64. external_repository: SukkaLab/ruleset.skk.moe
  65. publish_branch: master
  66. publish_dir: public
  67. cname: ruleset.skk.moe