Last active
October 2, 2020 12:51
-
-
Save fkirc/352f6da86ff18ee7d70e3dc8b1197e71 to your computer and use it in GitHub Desktop.
Capacitor Cross-platform GitHub Action: npm + Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
pre_job: | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
github_token: ${{ github.token }} | |
paths_ignore: '["**/*.md"]' | |
ci: | |
needs: pre_job | |
if: ${{ needs.pre_job.outputs.should_skip == 'false' }} | |
runs-on: ubuntu-latest # For enterprise users, macos is 10x more expensive (as of 9/2020) | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.CI_PAT }} # Recursive workflow-triggering does not work with regular GitHub token | |
- uses: actions/cache@v2 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- run: pwd && ls -la | |
- run: yarn install --frozen-lockfile | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
github_token: ${{ github.token }} | |
cancel_others: 'false' | |
paths: '["**/public/locales/**"]' | |
- name: Re-generate translations | |
if: ${{ steps.skip_check.outputs.should_skip == 'false' }} | |
run: | | |
git diff --exit-code | |
./translate.sh | |
git config --global user.name "Automated Translations" | |
git config --global user.email "[email protected]" | |
git commit -am "Re-generate translations" || true | |
git diff --exit-code | |
git push origin | |
- run: yarn run lint | |
- run: yarn run build | |
- run: git submodule update --init | |
- run: npx cap sync android | |
- name: Android Tests | |
run: | | |
git fetch origin --depth=1 ${{ env.ref-branch }} | |
if ! git diff --name-only origin/${{ env.ref-branch }} | grep android; then | |
echo "Skip Android tests because nothing changed" && exit 0 | |
fi | |
cd android && pwd | |
./gradlew lintProductionRelease | |
./gradlew app:testProductionReleaseUnitTest | |
env: | |
ref-branch: "develop" | |
#- name: Setup tmate session | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget -O - https://gist.githubusercontent.com/fkirc/352f6da86ff18ee7d70e3dc8b1197e71/raw > .github/workflows/ci.yml