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      - name: Set up bin paths and env
25        run: |
26          echo "::add-path::$(pwd)/bin"
27          echo "::set-env name=EXPO_ROOT_DIR::$(pwd)"
28      - name: Get yarn cache directory path
29        id: yarn-cache-dir-path
30        run: echo "::set-output name=dir::$(yarn cache dir)"
31      - uses: actions/cache@v1
32        with:
33          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34          key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
35          restore-keys: |
36            ${{ runner.os }}-yarn-
37      - run: yarn install --frozen-lockfile
38      - uses: actions/cache@v1
39        with:
40          path: ~/.gradle/caches
41          key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }}
42          restore-keys: |
43            ${{ runner.os }}-gradle-
44      - uses: actions/cache@v2
45        id: cache-android-ndk
46        with:
47          path: /usr/local/lib/android/sdk/ndk/19.2.5345600/
48          key: ${{ runner.os }}-ndk-19.2.5345600
49          restore-keys: |
50            ${{ runner.os }}-ndk-
51      - name: Install NDK
52        if: steps.cache-android-ndk.outputs.cache-hit != 'true'
53        run: |
54          sudo $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;19.2.5345600"
55      - name: Build Android packages
56        env:
57          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
58        run: expotools android-build-packages --packages all
59      - name: Build shell app tarball
60        run: ./buildAndroidTarballLocally.sh
61      - name: Make an artifact
62        uses: actions/upload-artifact@v2
63        with:
64          name: android-shell-app
65          path: artifacts/android-shell-builder.tar.gz
66      - run: sudo apt-get install awscli
67      - name: Upload shell app tarball to S3
68        if: ${{ github.event_name == 'workflow_dispatch' }}
69        env:
70          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
71          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
72          S3_URI: s3://exp-artifacts/android-shell-builder-${{ github.sha }}.tar.gz
73        run: |
74          aws s3 cp --acl public-read artifacts/android-shell-builder.tar.gz $S3_URI
75          echo "Release tarball uploaded to $S3_URI"
76          echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/android"
77          echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
78      - name: Set the description for slack message
79        if: ${{ github.event_name != 'push' }}
80        run: |
81          if [ ${{ github.event_name }} == 'schedule' ]; then
82            echo "::set-env name=SLACK_MESSAGE_DESCRIPTION::scheduled"
83          else
84            echo "::set-env name=SLACK_MESSAGE_DESCRIPTION::triggered by ${{ github.actor }}"
85          fi
86      - uses: 8398a7/action-slack@v3
87        if: ${{ github.event_name != 'push' }}
88        env:
89          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ANDROID }}
91        with:
92          channel: '#platform-android'
93          status: ${{ job.status }}
94          fields: job,commit,ref,eventName,author,took
95          author_name: Android Shell App (${{ env.SLACK_MESSAGE_DESCRIPTION }})
96