1name: Android Shell App
2
3on:
4  workflow_dispatch: {}
5  schedule:
6    - cron: '20 5 * * 2,4,6' # 5:20 AM UTC time on every Tuesday, Thursday and Saturday
7  push:
8    paths:
9      - .github/workflows/shell-app-android.yml
10
11jobs:
12  build:
13    runs-on: ubuntu-18.04
14    steps:
15      - uses: actions/checkout@v2
16      - name: Get cache key of git lfs files
17        id: git-lfs
18        run: echo "::set-output name=sha256::$(git lfs ls-files | openssl dgst -sha256)"
19      - uses: actions/cache@v2
20        with:
21          path: .git/lfs
22          key: ${{ steps.git-lfs.outputs.sha256 }}
23      - run: git lfs pull
24      - run: echo "$(pwd)/bin" >> $GITHUB_PATH
25      - run: echo "EXPO_ROOT_DIR=$(pwd)" >> $GITHUB_ENV
26      - name: Get yarn cache directory path
27        id: yarn-cache-dir-path
28        run: echo "::set-output name=dir::$(yarn cache dir)"
29      - uses: actions/cache@v2
30        with:
31          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32          key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
33          restore-keys: |
34            ${{ runner.os }}-yarn-
35      - run: yarn install --frozen-lockfile
36      - uses: actions/cache@v2
37        with:
38          path: ~/.gradle/caches
39          key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }}
40          restore-keys: |
41            ${{ runner.os }}-gradle-
42      - uses: actions/cache@v2
43        id: cache-android-ndk
44        with:
45          path: /usr/local/lib/android/sdk/ndk/19.2.5345600/
46          key: ${{ runner.os }}-ndk-19.2.5345600
47          restore-keys: |
48            ${{ runner.os }}-ndk-
49      - name: Install NDK
50        if: steps.cache-android-ndk.outputs.cache-hit != 'true'
51        run: |
52          sudo $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;19.2.5345600"
53      - name: Build Android packages
54        env:
55          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
56        run: expotools android-build-packages --packages all
57      - name: Clean Android build artifacts that would needlessly bloat the shell app
58        env:
59          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
60        run: ./gradlew clean
61        working-directory: android
62      - name: Build shell app tarball
63        run: ./buildAndroidTarballLocally.sh
64      - name: Make an artifact
65        uses: actions/upload-artifact@v2
66        with:
67          name: android-shell-app
68          path: artifacts/android-shell-builder.tar.gz
69      - run: sudo apt-get install awscli
70      - name: Upload shell app tarball to S3
71        if: ${{ github.event_name == 'workflow_dispatch' }}
72        env:
73          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
74          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
75          S3_URI: s3://exp-artifacts/android-shell-builder-${{ github.sha }}.tar.gz
76        run: |
77          aws s3 cp --acl public-read artifacts/android-shell-builder.tar.gz $S3_URI
78          echo "Release tarball uploaded to $S3_URI"
79          echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/android"
80          echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
81      - name: Set the description for slack message
82        if: ${{ github.event_name != 'push' }}
83        run: |
84          if [ ${{ github.event_name }} == 'schedule' ]; then
85            echo "SLACK_MESSAGE_DESCRIPTION=scheduled" >> $GITHUB_ENV
86          else
87            echo "SLACK_MESSAGE_DESCRIPTION=triggered by ${{ github.actor }}" >> $GITHUB_ENV
88          fi
89      - uses: 8398a7/action-slack@v3
90        if: ${{ github.event_name != 'push' }}
91        env:
92          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ANDROID }}
94        with:
95          channel: '#platform-android'
96          status: ${{ job.status }}
97          fields: job,message,ref,eventName,author,took
98          author_name: Android Shell App (${{ env.SLACK_MESSAGE_DESCRIPTION }})
99