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

GitHub Actionsのカスタムアクションを公開する

yorifuji
December 14, 2023

GitHub Actionsのカスタムアクションを公開する

yorifuji

December 14, 2023
Tweet

More Decks by yorifuji

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • YORIFUJI MITSUNORI • @yorifuji on X / GitHub

    / Zenn • ۚ༥ܥελʔτΞοϓͷiOSΤϯδχΞ
  2. GitHub ActionsͰFlutterͷ ੩తղੳΛ࣮ߦ͢ΔϫʔΫ ϑϩʔͷྫʢyamlϑΝΠ ϧʣ name: check on: pull_request permissions:

    contents: read jobs: analysis: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 - run: flutter pub get - run: flutter analyze
  3. ࠓճ͸ϫʔΫϑϩʔͷ࡞Γ ํͰ͸ͳ͘ɺϫʔΫϑϩʔ Ͱར༻͢ΔΞΫγϣϯΛ࡞ ੒͢Δ࿩ name: check on: pull_request permissions: contents:

    read jobs: analysis: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 - run: flutter pub get - run: flutter analyze
  4. ࢖͍ํ͸ϫʔΫϑϩʔʹ ΞΫγϣϯΛ௥Ճ͢Δͩ ͚ name: flutter-analyze-commenter example on: pull_request permissions: contents:

    read pull-requests: write jobs: analysis: runs-on: ubuntu-latest steps: ... - run: flutter analyze --write=flutter_analyze.log - uses: yorifuji/flutter-analyze-commenter@v1 if: ${{ !cancelled() }} with: analyze_log: flutter_analyze.log
  5. MarketplaceʹΞΫγϣϯΛొ࿥͢Δखॱ • ͜Ε͚ͩ • GitHubʹpublic repositoryΛ࡞੒ • ΞΫγϣϯͷఆٛΛॻ͍ͨaction.ymlΛ࡞੒ • ΧελϜΞΫγϣϯͷॲཧΛ࣮૷

    • GitHub্ͰReleaseΛ࡞੒ͯ͠ެ։ • ৄ͍͠खॱ͸ͪ͜Β • https://docs.github.com/ja/actions/creating-actions/publishing-actions-in-github- marketplace
  6. action.yml ͷهड़ྫʢ࣮ࡍͷΞΫγϣϯ͔Βൈਮʣ name: "Flutter Analyze Commenter" description: "Auto comment on

    PRs based on Flutter Analyze results" inputs: analyze_log: description: "Path to the Flutter analyze log" required: true runs: using: composite steps: - uses: actions/github-script@v7 env: ANALYZE_LOG: ${{ inputs.analyze_log }} VERBOSE: ${{ inputs.verbose }} with: script: | const analyzeLog = process.env.ANALYZE_LOG; ...
  7. ΧελϜΞΫγϣϯͷ࣮૷ํ๏ • Docker ίϯςφʔ ΞΫγϣϯ • ίϯςφΛ࢖࣮ͬͯߦ؀ڥΛύοέʔδԽ͢Δํࣜ • ඞཁͳπʔϧ΍ґଘؔ܎ΛίϯςφͰ؅ཧͰ͖ΔͷͰҰ؏ੑͱ৴པੑΛ୲อ͠΍͍͢ •

    ݱঢ়͸Linuxʢubuntuʣ ͷϥϯφʔͰͷΈར༻Ͱ͖ΔʢmacOS΍Windows͸ར༻ෆՄʣ • JavaScript ΞΫγϣϯ • Node.jsΛ࢖ͬͯJavaScriptͷίʔυΛ࣮ߦ͢ΔΞΫγϣϯ • TypeScriptͰͷ։ൃ΋Մೳʢ࠷ऴతʹJavaScript͕ੜ੒Ͱ͖ΔͳΒͳΜͰ΋ྑ͍ʣɺෳࡶͳ࣮૷Λ͢ΔͳΒ͓͢͢Ί • ෳ߹ΞΫγϣϯʢComosite Actionʣ • ීஈ࢖͍ͬͯΔϫʔΫϑϩʔ͔ΒॲཧΛ੾Γग़͢Πϝʔδ • γΣϧεΫϦϓτͰͷ࣮૷͕جຊ • uses: ͕ར༻ՄೳͳͷͰ௨ৗͷΞΫγϣϯ΋ར༻Ͱ͖Δ
  8. actions/github-script // ྫɿhello world - uses: actions/github-script@v7 with: script: console.log('Hello,

    JavaScript') // ྫɿGithubͷREST APIΛ࢖ͬͯIssueΛऔಘ - uses: actions/github-script@v7 with: script: | github.rest.issues.get({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, }) • ෳ߹ΞΫγϣϯͰJavaScriptΛ࢖ͬͨॲ ཧΛهड़Ͱ͖ΔΞΫγϣϯ