diff --git a/.github/workflows/maestro-test.yml b/.github/workflows/maestro-test.yml index 1c4b7dc2..a34be714 100644 --- a/.github/workflows/maestro-test.yml +++ b/.github/workflows/maestro-test.yml @@ -100,6 +100,10 @@ jobs: with: name: android-artifacts path: artifacts/ + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.4' # Not needed with a .ruby-version, .tool-versions or mise.toml + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Enable KVM group perms shell: bash @@ -128,18 +132,14 @@ jobs: - name: 🗣️ Notify Success on Discord if: success() run: | - cd ios - bundle install && bundle exec fastlane notifyOnDiscord title:"✅ Maestro Tests Passed" description:"Maestro tests completed successfully" - cd .. + node scripts/sendDiscordMessage.js "__**## ✅ Maestro Test Passed**__All checks completed successfully!" env: DISCORD_WEBHOOK_URL: ${{ secrets.MAESTRO_WEBHOOK_RESULTS }} - name: 🗣️ Notify Failure on Discord if: failure() run: | - cd ios - bundle install && bundle exec fastlane notifyOnDiscord title:"❌ Maestro Tests Failed" description:"Maestro tests failed. Check the workflow logs for details." - cd .. + node scripts/sendDiscordMessage.js "__**## ❌ Maestro Test Failed**__Some tests did not pass." env: DISCORD_WEBHOOK_URL: ${{ secrets.MAESTRO_WEBHOOK_RESULTS }} - name: Store tests result diff --git a/.github/workflows/publish-ota-update-pr.yml b/.github/workflows/publish-ota-update-pr.yml index 54dd8c53..3a40fa73 100644 --- a/.github/workflows/publish-ota-update-pr.yml +++ b/.github/workflows/publish-ota-update-pr.yml @@ -3,7 +3,10 @@ on: pull_request: paths: - 'src/**' - + - 'App.tsx' + - '.github/workflows/publish-ota-update-pr.yml' + - 'scripts/ota-PR.sh' + - 'scripts/getRandomVersion.sh' jobs: publish-ota-update: runs-on: macos-15 diff --git a/scripts/getRandomVersion.sh b/scripts/getRandomVersion.sh index a750c6dd..c274dd25 100644 --- a/scripts/getRandomVersion.sh +++ b/scripts/getRandomVersion.sh @@ -3,6 +3,12 @@ set -euo pipefail FILE="ota.version" +# Check if --PR flag is passed +IS_PR=false +if [[ "${1:-}" == "--PR" ]]; then + IS_PR=true +fi + # Array of sentences sentences=( "Git Blame violet" @@ -44,9 +50,14 @@ new_sentence=$(get_random_sentence) alphanum_suffix=$(get_random_alphanum) version_string="${new_sentence} (${alphanum_suffix})" +# Prefix for PR builds +if $IS_PR; then + version_string="PULL_REQUEST - ${version_string}" +fi + # Write atomically tmp="${FILE}.tmp.$$" echo "$version_string" > "$tmp" mv "$tmp" "$FILE" -echo "✅ Updated $FILE with: \"$version_string\"" \ No newline at end of file +echo "✅ Updated $FILE with: \"$version_string\"" diff --git a/scripts/ota-PR.sh b/scripts/ota-PR.sh index 73e96e11..0d47271c 100644 --- a/scripts/ota-PR.sh +++ b/scripts/ota-PR.sh @@ -19,7 +19,7 @@ fi cd ../.. yarn createBundle:android cd android/App-Bundles -bash ../../scripts/getRandomVersion.sh +bash ../../scripts/getRandomVersion.sh --PR git add . git commit -m "OTA-Update - $(date +'%b %d %H:%M')" git push https://x-access-token:$SIGNING_REPO_PAT@github.com/Jellify-Music/App-Bundles.git "$target_branch" @@ -44,10 +44,10 @@ rm -rf Readme.md cd ../.. yarn createBundle:ios cd ios/App-Bundles -bash ../../scripts/getRandomVersion.sh +bash ../../scripts/getRandomVersion.sh --PR git add . git commit -m "OTA-Update - $(date +'%b %d %H:%M')" git push https://x-access-token:$SIGNING_REPO_PAT@github.com/Jellify-Music/App-Bundles.git "$target_branch" cd .. rm -rf App-Bundles -cd .. \ No newline at end of file +cd .. diff --git a/scripts/sendDiscordMessage.js b/scripts/sendDiscordMessage.js new file mode 100644 index 00000000..723e309f --- /dev/null +++ b/scripts/sendDiscordMessage.js @@ -0,0 +1,14 @@ +const WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL + +async function sendDiscordMessage(message) { + const res = await fetch(WEBHOOK_URL, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ content: message }), + }) + + console.log('Sent:', message) +} + +const msg = process.argv.slice(2).join(' ') +sendDiscordMessage(msg)