Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Devops-ify your life with Github Actions

Devops-ify your life with Github Actions

What's the first thing you should do when starting a new project...? Setup a good CI system!

With Github Actions you can do it in a couple of seconds. You can easily setup a workflow to build your project, test it on different machines, and deploy the results.

In this talk we're going to see how you can setup a simple Github Action for your repository and start enjoying it right after.

Nicola Corti

August 09, 2020
Tweet

More Decks by Nicola Corti

Other Decks in Technology

Transcript

  1. name: Build on: push: branches: - '*' pull_request: branches: -

    '*' jobs: gradle: runs-on: [ubuntu-latest]
  2. name: Build on: push: branches: - '*' pull_request: branches: -

    '*' jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2
  3. name: Build on: push: branches: - '*' pull_request: branches: -

    '*' jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Build everything run: ./gradlew assemble
  4. name: Build on: push: branches: - '*' pull_request: branches: -

    '*' jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Build everything run: ./gradlew assemble
  5. name: Build on: push: branches: - '*' pull_request: branches: -

    '*' jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Build everything run: ./gradlew assemble
  6. jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Run ktlint run: ./gradlew ktlintCheck - name: Run detekt run: ./gradlew detekt - name: Run all the tests run: ./gradlew test github.com/AppIntro/AppIntro
  7. jobs: gradle: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Run ktlint run: ./gradlew ktlintCheck - name: Run detekt run: ./gradlew detekt - name: Run all the tests run: ./gradlew test github.com/AppIntro/AppIntro
  8. jobs: ktlint: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Run ktlint run: ./gradlew ktlintCheck detekt: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run detekt run: ./gradlew detekt tests: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run all the tests run: ./gradlew test github.com/AppIntro/AppIntro
  9. jobs: ktlint: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Run ktlint run: ./gradlew ktlintCheck detekt: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run detekt run: ./gradlew detekt tests: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run all the tests run: ./gradlew test github.com/AppIntro/AppIntro
  10. jobs: ktlint: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Run ktlint run: ./gradlew ktlintCheck detekt: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run detekt run: ./gradlew detekt test: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Run all the tests run: ./gradlew test github.com/AppIntro/AppIntro
  11. jobs: build-debug-apk: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Build the Debug APK run: ./gradlew assembleDebug - uses: actions/upload-artifact@v2 with: name: appintro-sample-app.apk path: example/build/outputs/apk/debug/example-debug.apk github.com/AppIntro/AppIntro
  12. jobs: build-debug-apk: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Build the Debug APK run: ./gradlew assembleDebug - uses: actions/upload-artifact@v2 with: name: appintro-sample-app.apk path: example/build/outputs/apk/debug/example-debug.apk github.com/AppIntro/AppIntro
  13. jobs: build-debug-apk: runs-on: [ubuntu-latest] steps: - name: Checkout Repo uses:

    actions/checkout@v2 - name: Build the Debug APK run: ./gradlew assembleDebug - uses: actions/upload-artifact@v2 with: name: appintro-sample-app.apk path: example/build/outputs/apk/debug/example-debug.apk github.com/AppIntro/AppIntro
  14. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }}
  15. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }}
  16. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }} env: GRADLE_OPTS: -Dorg.gradle.daemon=false JDK_VERSION: ${{ matrix.jdk }} steps: - name: Checkout Repo uses: actions/checkout@v2
  17. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }} env: GRADLE_OPTS: -Dorg.gradle.daemon=false JDK_VERSION: ${{ matrix.jdk }} steps: - name: Checkout Repo uses: actions/checkout@v2
  18. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }} env: GRADLE_OPTS: -Dorg.gradle.daemon=false JDK_VERSION: ${{ matrix.jdk }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Setup Java uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }}
  19. github.com/detekt/detekt/ jobs: gradle: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} strategy:

    fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] jdk: [8, 11, 14] runs-on: ${{ matrix.os }} env: GRADLE_OPTS: -Dorg.gradle.daemon=false JDK_VERSION: ${{ matrix.jdk }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Setup Java uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }}
  20. name: Release to Play Store on: push: branches: - release

    jobs: gradle: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build with Gradle run: ./gradlew bundleRelease
  21. branches: - release jobs: gradle: runs-on: ubuntu-latest steps: - uses:

    actions/checkout@v2 - name: Build with Gradle run: ./gradlew bundleRelease - name: Sign Android release uses: r0adkll/sign-android-release@v1 with: # The directory to find your release to sign releaseDirectory: app/build/outputs/bundle/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} keyPassword: ${{ secrets.KEY_PASSWORD }}
  22. branches: - release jobs: gradle: runs-on: ubuntu-latest steps: - uses:

    actions/checkout@v2 - name: Build with Gradle run: ./gradlew bundleRelease - name: Sign Android release uses: r0adkll/sign-android-release@v1 with: # The directory to find your release to sign releaseDirectory: app/build/outputs/bundle/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} keyPassword: ${{ secrets.KEY_PASSWORD }}
  23. run: ./gradlew bundleRelease - name: Sign Android release uses: r0adkll/sign-android-release@v1

    with: # The directory to find your release to sign releaseDirectory: app/build/outputs/bundle/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} keyPassword: ${{ secrets.KEY_PASSWORD }} - name: Upload Android Release to Play Store uses: r0adkll/[email protected] with: serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} packageName: it.gdgdevparty.sample releaseFile: app/build/outputs/bundle/release/app-release.aab track: beta
  24. name: Release to Play Store on: push: branches: - release

    jobs: gradle: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build with Gradle run: ./gradlew bundleRelease - name: Sign Android release uses: r0adkll/sign-android-release@v1 with: # The directory to find your release to sign releaseDirectory: app/build/outputs/bundle/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} keyPassword: ${{ secrets.KEY_PASSWORD }} - name: Upload Android Release to Play Store uses: r0adkll/[email protected] with: serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} packageName: it.gdgdevparty.sample releaseFile: app/build/outputs/bundle/release/app-release.aab track: beta
  25. github.com/ChuckerTeam/chucker jobs: detekt: runs-on: [ubuntu-latest] steps: - name: Checkout Repo

    uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ hashFiles('build.gradle') }} restore-keys: cache-gradle- - name: Run detekt run: ./gradlew detekt - name: Stop Gradle run: ./gradlew #--stop
  26. github.com/ChuckerTeam/chucker jobs: detekt: runs-on: [ubuntu-latest] steps: - name: Checkout Repo

    uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ hashFiles('build.gradle') }} restore-keys: cache-gradle- - name: Run detekt run: ./gradlew detekt - name: Stop Gradle run: ./gradlew #--stop
  27. github.com/ChuckerTeam/chucker jobs: test: runs-on: [ubuntu-latest] strategy: fail-fast: false matrix: kotlin-version:

    - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{ matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle run: ./gradlew --stop
  28. github.com/ChuckerTeam/chucker jobs: test: runs-on: [ubuntu-latest] strategy: fail-fast: false matrix: kotlin-version:

    - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{ matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle run: ./gradlew --stop
  29. github.com/ChuckerTeam/chucker jobs: test: runs-on: [ubuntu-latest] strategy: fail-fast: false matrix: kotlin-version:

    - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{ matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle run: ./gradlew --stop
  30. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle
  31. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750
  32. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750 cache-gradle-1.4-M3-ddea0750 cache-gradle-1.3.72-feb253ff cache-gradle-1.4-M3-feb253ff Cache cache-gradle-1.3.72-ddea0750
  33. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750 cache-gradle-1.4-M3-ddea0750 cache-gradle-1.3.72-feb253ff cache-gradle-1.4-M3-feb253ff Cache cache-gradle-1.3.72-017fd2
  34. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750 cache-gradle-1.4-M3-ddea0750 cache-gradle-1.3.72-feb253ff cache-gradle-1.4-M3-feb253ff Cache cache-gradle-1.3.72-017fd2
  35. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750 cache-gradle-1.4-M3-ddea0750 cache-gradle-1.3.72-feb253ff cache-gradle-1.4-M3-feb253ff Cache cache-gradle-1.4.0-017fd2
  36. github.com/ChuckerTeam/chucker matrix: kotlin-version: - 1.3.72 - 1.4-M3 env: KOTLIN_VERSION: ${{

    matrix.kotlin-version }} steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Cache Gradle Folders uses: actions/cache@v2 with: path: | ~/.gradle/caches/ ~/.gradle/wrapper/ key: cache-gradle-${{ matrix.kotlin-version }}-${{ hashFiles('build.gradle') }} restore-keys: | cache-gradle-${{ matrix.version }}- cache-gradle- - name: Run all the tests run: ./gradlew test - name: Stop Gradle cache-gradle-1.3.72-ddea0750 cache-gradle-1.4-M3-ddea0750 cache-gradle-1.3.72-feb253ff cache-gradle-1.4-M3-feb253ff Cache cache-gradle-1.4.0-017fd2