toggle-dist-repo-visibility.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. name: Toggle Dist Repo Visibility
  2. on:
  3. schedule:
  4. # Runs at 22:47 UTC every Sunday
  5. # This also avoids hitting our own auto build schedule at 05:17 and 17:17 UTC
  6. - cron: '47 14 * * 0'
  7. workflow_dispatch:
  8. concurrency:
  9. group: ${{ github.workflow }}
  10. cancel-in-progress: true
  11. jobs:
  12. toggle_dist_repo_visibility:
  13. name: Toggle Dist Repo Visibility
  14. runs-on: ubuntu-slim
  15. steps:
  16. - name: Make dist repo private
  17. env:
  18. GH_TOKEN: ${{ secrets.GIT_TOKEN }}
  19. run: |
  20. gh repo unarchive SukkaLab/ruleset.skk.moe --yes
  21. gh repo edit SukkaLab/ruleset.skk.moe \
  22. --visibility private \
  23. --accept-visibility-change-consequences
  24. - name: Wait for visibility change to settle
  25. run: sleep 180
  26. - name: Make dist repo public again
  27. env:
  28. GH_TOKEN: ${{ secrets.GIT_TOKEN }}
  29. run: |
  30. gh repo edit SukkaLab/ruleset.skk.moe \
  31. --visibility public \
  32. --accept-visibility-change-consequences
  33. - name: Restore GitHub Pages branch deployment
  34. env:
  35. GH_TOKEN: ${{ secrets.GIT_TOKEN }}
  36. # After we toggle the visibility, GitHub Pages WILL get taken down
  37. # But just in case, we still detect and use both PUT/POST
  38. run: |
  39. if gh api repos/SukkaLab/ruleset.skk.moe/pages >/dev/null 2>&1; then
  40. gh api \
  41. --method PUT \
  42. -H "Accept: application/vnd.github+json" \
  43. -H "X-GitHub-Api-Version: 2026-03-10" \
  44. repos/SukkaLab/ruleset.skk.moe/pages \
  45. -f "build_type=legacy" \
  46. -f "source[branch]=master" \
  47. -f "source[path]=/"
  48. else
  49. gh api \
  50. --method POST \
  51. -H "Accept: application/vnd.github+json" \
  52. -H "X-GitHub-Api-Version: 2026-03-10" \
  53. repos/SukkaLab/ruleset.skk.moe/pages \
  54. -f "build_type=legacy" \
  55. -f "source[branch]=master" \
  56. -f "source[path]=/"
  57. fi
  58. - name: Archive dist repo again
  59. env:
  60. GH_TOKEN: ${{ secrets.GIT_TOKEN }}
  61. run: |
  62. gh repo archive SukkaLab/ruleset.skk.moe --yes