scheduled.yaml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. name: Scheduled
  2. run-name: Scheduled Repository Actions ⏰
  3. on:
  4. schedule:
  5. - cron: 17 0 * * *
  6. permissions:
  7. contents: write
  8. concurrency:
  9. group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
  10. cancel-in-progress: true
  11. jobs:
  12. services-availability:
  13. name: Check Service Availability 🛜
  14. if: github.repository_owner == 'obsproject'
  15. runs-on: macos-14
  16. permissions:
  17. checks: write
  18. contents: write
  19. pull-requests: write
  20. steps:
  21. - uses: actions/checkout@v4
  22. with:
  23. fetch-depth: 0
  24. - name: Set Up Homebrew 🍺
  25. uses: Homebrew/actions/setup-homebrew@master
  26. - name: Check for Defunct Services 📉
  27. uses: ./.github/actions/services-validator
  28. with:
  29. repositorySecret: ${{ secrets.GITHUB_TOKEN }}
  30. checkApiSecret: ${{ secrets.CHECK_SERVERS_API_KEY }}
  31. checkApiServers: ${{ secrets.CHECK_SERVERS_LIST }}
  32. runSchemaChecks: false
  33. runServiceChecks: true
  34. createPullRequest: true
  35. cache-cleanup:
  36. name: Cache Cleanup 🧹
  37. runs-on: ubuntu-24.04
  38. permissions:
  39. actions: write
  40. steps:
  41. - name: Remove Stale Ccache Caches
  42. env:
  43. GH_TOKEN: ${{ github.token }}
  44. run: |
  45. : Remove Stale Ccache Caches
  46. # The jq expressions below use multiple 'select' calls to filter
  47. # each item in the array with the 'actions_caches' key.
  48. # First it only selects objects whose 'ref' element has the value
  49. # 'refs/heads/master', of those objects only those whose 'key'
  50. # value matches the specifies expression, before finally only
  51. # selecting the 'id' and 'key' elements for a new object.
  52. # The final 'join' command combines both elements with a semicolon
  53. # into a raw string which can then be parsed directly.
  54. echo '::group::Processing master branch cache entries'
  55. while IFS=";" read -r cache_id cache_name; do
  56. if [[ "${cache_name}" ]]; then
  57. result=true
  58. gh api -X DELETE repos/${GITHUB_REPOSITORY}/actions/caches?key=${cache_name} --jq '.total_count' &> /dev/null || result=false
  59. if ${result}; then
  60. echo "Deleted cache entry ${cache_name}"
  61. else
  62. echo "::warning::Unable to delete cache entry ${cache_name}"
  63. fi
  64. fi
  65. done <<< \
  66. "$(gh api repos/${GITHUB_REPOSITORY}/actions/caches \
  67. --jq '.actions_caches.[] | select(.ref|test("refs/heads/master")) | select(.key|test(".*-ccache-*")) | {id, key} | join(";")')"
  68. echo '::endgroup::'
  69. echo '::group::Processing pull request cache entries'
  70. while IFS=";" read -r cache_id cache_name cache_ref; do
  71. if [[ "${cache_name}" ]]; then
  72. result=true
  73. gh api -X DELETE repos/${GITHUB_REPOSITORY}/actions/caches?key=${cache_name} --jq '.total_count' &> /dev/null || result=false
  74. pr_number=$(echo ${cache_ref} | cut -d '/' -f 3)
  75. if ${result}; then
  76. echo "Deleted PR #${pr_number} cache entry ${cache_name}"
  77. else
  78. echo "::warning::Unable to delete PR #${pr_number} cache entry ${cache_name}"
  79. fi
  80. fi
  81. done <<< \
  82. "$(gh api repos/${GITHUB_REPOSITORY}/actions/caches \
  83. --jq '.actions_caches.[] | select(.ref|test("refs/heads/master")|not) | select(.key|test(".*-ccache-*")) | {id, key, ref} | join(";")')"
  84. echo '::endgroup::'
  85. build-project:
  86. name: Build 🧱
  87. uses: ./.github/workflows/build-project.yaml
  88. needs: cache-cleanup
  89. secrets: inherit
  90. analyze-project:
  91. name: Analyze 🔬
  92. uses: ./.github/workflows/analyze-project.yaml
  93. needs: cache-cleanup
  94. secrets: inherit
  95. permissions:
  96. security-events: write
  97. upload-language-files:
  98. name: Upload Language Files 🌐
  99. if: github.repository_owner == 'obsproject' && github.ref_name == 'master'
  100. runs-on: ubuntu-24.04
  101. steps:
  102. - uses: actions/checkout@v4
  103. with:
  104. submodules: recursive
  105. fetch-depth: 0
  106. - name: Check Nightly Runs ☑️
  107. id: nightly-checks
  108. env:
  109. GH_TOKEN: ${{ github.token }}
  110. run: |
  111. : Check Nightly Runs ☑️
  112. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  113. # This 'gh' command retrieves the last 2 runs of the workflow defined
  114. # by 'scheduled.yaml' and retrieve only the 'headSha' value of the
  115. # JSON response payload.
  116. #
  117. # As this job runs in context of the same workflow, the first element
  118. # of the workflow list will be the currently active run.
  119. #
  120. # The jq expression then selects the 'headSha' element of the second
  121. # element in the array, which is the SHA-1 hash of the commit used
  122. # for the immediately prior run of this workflow.
  123. last_nightly=$(gh run list --workflow scheduled.yaml --limit 2 --json headSha --jq '.[1].headSha')
  124. if [[ "${GITHUB_SHA}" == "${last_nightly}" ]]; then
  125. echo "passed=false" >> $GITHUB_OUTPUT
  126. else
  127. echo "passed=true" >> $GITHUB_OUTPUT
  128. echo "lastNightly=${last_nightly}" >> $GITHUB_OUTPUT
  129. fi
  130. - name: Check for Changed Files ✅
  131. if: fromJSON(steps.nightly-checks.outputs.passed)
  132. uses: ./.github/actions/check-changes
  133. id: checks
  134. with:
  135. baseRef: ${{ steps.nightly-checks.outputs.lastNightly }}
  136. checkGlob: '**/en-US.ini'
  137. - name: Upload US English Language Files 🇺🇸
  138. if: steps.checks.outcome == 'success' && fromJSON(steps.checks.outputs.hasChangedFiles)
  139. uses: obsproject/obs-crowdin-sync/upload@84628cad04d2423e02443c64965cb834b4c5a245
  140. env:
  141. CROWDIN_PAT: ${{ secrets.CROWDIN_SYNC_CROWDIN_PAT }}
  142. GITHUB_EVENT_BEFORE: ${{ steps.nightly-checks.outputs.lastNightly }}
  143. steam-upload:
  144. name: Upload Steam Builds 🚂
  145. needs: [build-project]
  146. if: github.repository_owner == 'obsproject'
  147. runs-on: macos-14
  148. defaults:
  149. run:
  150. shell: zsh --no-rcs --errexit --pipefail {0}
  151. steps:
  152. - uses: actions/checkout@v4
  153. - name: Check Nightly Runs ☑️
  154. id: checks
  155. env:
  156. GH_TOKEN: ${{ github.token }}
  157. run: |
  158. : Check Nightly Runs ☑️
  159. if (( ${+RUNNER_DEBUG} )) setopt XTRACE
  160. # This 'gh' command retrieves the last 2 runs of the workflow defined
  161. # by 'scheduled.yaml' and retrieve only the 'headSha' value of the
  162. # JSON response payload.
  163. #
  164. # As this job runs in context of the same workflow, the first element
  165. # of the workflow list will be the currently active run.
  166. #
  167. # The jq expression then selects the 'headSha' element of the second
  168. # element in the array, which is the SHA-1 hash of the commit used
  169. # for the immediately prior run of this workflow.
  170. local last_nightly=$(gh run list --workflow scheduled.yaml --limit 2 --json headSha --jq '.[1].headSha')
  171. if [[ "${GITHUB_SHA}" == "${last_nightly}" ]] {
  172. print "passed=false" >> $GITHUB_OUTPUT
  173. } else {
  174. print "passed=true" >> $GITHUB_OUTPUT
  175. }
  176. - uses: ./.github/actions/steam-upload
  177. if: fromJSON(steps.checks.outputs.passed)
  178. with:
  179. steamSecret: ${{ secrets.STEAM_SHARED_SECRET }}
  180. steamUser: ${{ secrets.STEAM_USER }}
  181. steamPassword: ${{ secrets.STEAM_PASSWORD }}
  182. workflowSecret: ${{ secrets.GITHUB_TOKEN }}
  183. preview: ${{ github.repository_owner != 'obsproject' }}