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

Custom GitHub Actions を作って Organization 内で共有する

Custom GitHub Actions を作って Organization 内で共有する

YUMEMI.apk #6 ( https://yumemi.connpass.com/event/243080/ ) の資料

D8281434c0409ba2051cd3f7590e4c2f?s=128

Hiroyuki Kusu

April 28, 2022
Tweet

More Decks by Hiroyuki Kusu

Other Decks in Technology

Transcript

  1. Custom GitHub Actions Λ࡞ͬͯ Organization ಺Ͱڞ༗͢Δ 2022.4.28 YUMEMI.apk #6 Android

    DevOps WG ( ϫʔΩϯάɾάϧʔϓ ) Hiroyuki Kusu ( @hkusu_ )
  2. About me 

  3. 5000ສਓͷΈΜͳ͕஌ͬͯΔ͋ͷαʔϏεɺ ΏΊΈ͕Ұॹʹ࡞ͬͯ·͢ɻ େखاۀ΍ٸ੒௕ελʔτΞοϓͱڞ૑ܕͰWeb/εϚϗͷαʔϏε࡞Γ΍಺੡ԽࢧԉΛߦ͍ͬͯ·͢ɻ ʲΤϯδχΞ͕࠷΋੒௕Ͱ͖ΔձࣾNO.1ʳΛ໨ඪʹͨ͠ɺΞδϟΠϧ૊৫ͱͯ͠ઌ୺Λ૸ΔΤϯδχΞूஂͰ͢ɻ 

  4.  - name: Check ou t uses: actions/checkout@v 3 -

    name: Set up JD K uses: actions/setup-java@v 2 with : distribution: 'zulu ' java-version: 1 1 cache: 'gradle ' - name: Buil d run: ./gradlew assembleDebug Gradleͷґଘؔ܎ΛΩϟογϡ͢Δػೳ͸ҰԠ͋Δ͕.. actions/setup-java Android ΞϓϦΛϏϧυ͢ΔϫʔΫϑϩʔͷྫ
  5.  buildSrc ΍ Android ͷόʔδϣϯΧλϩά͸ߟྀ͍ͯ͠ͳͦ͏..

  6.  - name: Set up JD K uses: actions/setup-java@v 2

    with : distribution: 'zulu ' java-version: 1 1 - name: Restore gradle cach e uses: actions/cache@v 3 with : path: | ~/.gradle/cache s ~/.gradle/wrappe r key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/src/*', '**/libs.versions.toml') } } restore-keys: | ${{ runner.os }}-gradle- ௕͍͠ར༻Օॴ΋ଟ͍.. Ͱ͖Ε͹ଞͷϫʔΫϑϩʔ΍ ଞͷϦϙδτϦͱڞ༗͍ͨ͠ʂ actions/cache ͰରԠ
  7.  https://docs.github.com/ja/actions/creating-actions/about-custom-actions Custom GitHub Actions

  8.  • Custom Actions ͸ public ϦϙδτϦͰ͋Δඞཁ͕͋Δ • Actions ͷίʔυΛखݩʹ

    clone ͯ͠ར༻͢Δख΋͋Δ͕ɺͦͷҝ ͷτʔΫϯ͕ผ్ ඞཁͩ͠ɺԿΑΓ΍΍͍͜͠..
  9.  https://github.blog/changelog/2022-01-21-share-github-actions-within-your-enterprise/ ※ GitHub ͷܖ໿ϓϥϯ΍ Organization ͷϙϦγʔʹΑͬͯར༻Ͱ͖ͳ͍͔΋ͳͷͰ஫ҙ͍ͩ͘͞ Organization ͷ internal

    ϦϙδτϦ͕ར༻Ͱ͖ΔΑ͏ʹʂ
  10.  internal ϦϙδτϦͰ࡞੒

  11.  name: 'Setup Java for Android ' description: 'Set up

    Java for Android and also cache Gradle dependencies. ’ inputs : distribution : description: 'Java distribution. Default is `zulu`. ' required: fals e default: 'zulu ' java-version : description: 'Java version. Default is `11`. ' required: fals e default: '11 ' skip-cache : description: 'Whether to skip cache restores and pushes. Default is `false`. ' required: fals e default: 'false ' outputs : cache-hit : description: 'A boolean value to indicate an exact match was found for the primary key. ' value: ${{ steps.cache.outputs.cache-hit } } runs : using: 'composite ' steps : - name: Set up JDK uses: actions/setup-java@v 2 with : distribution: ${{ inputs.distribution } } java-version: ${{ inputs.java-version } } - name: Restore gradle cach e if: inputs.skip-cache != 'true ' id: cach e uses: actions/cache@v3 with : path: | ~/.gradle/cache s ~/.gradle/wrappe r key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/src/*', '**/libs.versions.toml') } } restore-keys: | ${{ runner.os }}-gradle - ΦϓγϣϯͰڍಈΛมߋͰ͖ΔΑ͏ʹ
  12.  - name: Set up JD K uses: actions/setup-java@v 2

    with : distribution: 'zulu ' java-version: 1 1 - name: Restore gradle cach e uses: actions/cache@v 3 with : path: | ~/.gradle/cache s ~/.gradle/wrappe r key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/src/*', '**/libs.versions.toml') } } restore-keys: | ${{ runner.os }}-gradle- - name: Set up Jav a uses: yumemi/setup-java-for-android@v1 ద༻ޙ ద༻લ
  13. ͦͷଞ ΍͓͍ͬͯͨํ͕Α͍͜ͱ 

  14.  name: Cache Generatio n on : push : branches:

    # σϑΥϧτϒϥϯν΍ओͨΔϚʔδઌϒϥϯν܊Λࢦఆ - mai n - develop * jobs : generate : name: Generat e runs-on: ubuntu-20.0 4 steps : - name: Check ou t uses: actions/checkout@v 3 - name: Set up Jav a id: cach e uses: yumemi/setup-java-for-android@v 1 - name: Download dependencie s if: steps.cache.outputs.cache-hit != 'true ' run: ./gradlew androidDependencies Ϛʔδઌͷϒϥϯν΍σϑΥϧτϒϥϯνͰΩϟογϡΛ࡞͓ͬͯ͘ ϓϦϦΫΤετͰ Gradle ͷΩϟογϡΛར༻͍ͨ͠৔߹ ϓϧϦΫͷHEADϒϥϯνʹΩϟογϡ͕ແ͍৔߹ɺ ϓϧϦΫͷBASEϒϥϯν -> σϑΥϧτϒϥϯνͷॱ ͰΩϟογϡ͕ݕࡧ͞ΕΔɻ ௨ৗ͸ίʔυͷ௥Ճϓογϡ࣌ͷΈར༻Ͱ͖ΔΩϟγϡ͕ɺ ϓϧϦΫͷ৽نΦʔϓϯ࣌ʹ΋ར༻Ͱ͖ΔΑ͏ʹͳΔɻ
  15.  ֤ϦϙδτϦͰར༻͢ΔτʔΫϯΛڞ༗ Organization secrets

  16.  https://speakerdeck.com/hkusu/cd ͬͪ͜ͷεϥΠυ΋ΈͯͶ

  17. Thank you ! @hkusu_ ฐࣾ͸ Android ΤϯδχΞΛ ઈࢍืूத Ͱ͢ʂ