|
1 | 1 | on: |
2 | | - # schedule: |
3 | | - # - cron: "0 6 * * *" |
4 | | - workflow_dispatch |
| 2 | + workflow_dispatch: |
| 3 | + schedule: |
| 4 | + - cron: "0 6 * * *" # UTC |
5 | 5 |
|
6 | | -name: Nightly |
| 6 | +name: Deploy Nightly |
7 | 7 |
|
8 | 8 | concurrency: |
9 | 9 | group: nightly |
10 | 10 | cancel-in-progress: true |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - build: |
14 | | - name: Create Release |
| 13 | + check-and-deploy: |
| 14 | + name: Check Changes and Deploy Nightly |
15 | 15 | runs-on: ubuntu-latest |
16 | | - environment: nightly |
17 | 16 | permissions: |
18 | 17 | contents: write |
19 | 18 | steps: |
20 | 19 | - name: Checkout code |
21 | 20 | |
22 | | - - name: Set up Ruby |
23 | | - uses: ruby/setup-ruby@v1 |
24 | 21 | with: |
25 | | - bundler-cache: true |
26 | | - - name: Set up Java |
27 | | - |
28 | | - with: |
29 | | - distribution: "zulu" |
30 | | - java-version: "21" |
31 | | - - name: Build APK |
32 | | - env: |
33 | | - ENCODED_GOOGLE_SERVICES: ${{ secrets.ENCODED_GOOGLE_SERVICES }} |
34 | | - ENCODED_RELEASE_KEYSTORE: ${{ secrets.ENCODED_RELEASE_KEYSTORE }} |
35 | | - ENCODED_SECRETS_PROPERTIES: ${{ secrets.ENCODED_SECRETS_PROPERTIES }} |
36 | | - run: make deploy-free-nightly |
37 | | - - name: Create Release |
38 | | - uses: softprops/action-gh-release@v2 |
39 | | - env: |
40 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
41 | | - with: |
42 | | - generate_release_notes: true |
43 | | - draft: false |
44 | | - prerelease: true |
45 | | - files: | |
46 | | - app/build/outputs/apk/free/release/app-free-nightly.apk |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Get latest nightly tag |
| 25 | + id: latest-nightly |
| 26 | + run: | |
| 27 | + LATEST_NIGHTLY=$(git tag -l "*-nightly" --sort=-version:refname | head -n 1) |
| 28 | + echo "latest_nightly=${LATEST_NIGHTLY}" >> $GITHUB_OUTPUT |
| 29 | + echo "Latest nightly tag: ${LATEST_NIGHTLY}" |
| 30 | +
|
| 31 | + - name: Check for changes since last nightly |
| 32 | + id: check-changes |
| 33 | + run: | |
| 34 | + LATEST_NIGHTLY="${{ steps.latest-nightly.outputs.latest_nightly }}" |
| 35 | +
|
| 36 | + if [ -z "$LATEST_NIGHTLY" ]; then |
| 37 | + echo "No previous nightly tag found, proceeding with deployment" |
| 38 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 39 | + else |
| 40 | + # Check if there are any commits since the last nightly tag |
| 41 | + COMMITS_SINCE=$(git rev-list --count ${LATEST_NIGHTLY}..HEAD) |
| 42 | + echo "Commits since ${LATEST_NIGHTLY}: ${COMMITS_SINCE}" |
| 43 | +
|
| 44 | + if [ "$COMMITS_SINCE" -eq "0" ]; then |
| 45 | + echo "No changes since last nightly tag" |
| 46 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 47 | + else |
| 48 | + echo "Found ${COMMITS_SINCE} commits since last nightly tag" |
| 49 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 50 | + fi |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Exit if no changes |
| 54 | + if: steps.check-changes.outputs.has_changes == 'false' |
| 55 | + run: | |
| 56 | + echo "No changes detected since last nightly tag. Exiting without creating new nightly." |
| 57 | + exit 0 |
| 58 | +
|
| 59 | + - name: Create nightly tag |
| 60 | + if: steps.check-changes.outputs.has_changes == 'true' |
| 61 | + run: | |
| 62 | + NIGHTLY_TAG="$(date +'%Y.%m.%d')-nightly" |
| 63 | + echo "Creating nightly tag: ${NIGHTLY_TAG}" |
| 64 | + git tag "${NIGHTLY_TAG}" |
| 65 | + git push origin ${NIGHTLY_TAG} |
0 commit comments