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

社内パッケージの再利用にSatisを使っている話.pdf

kin29
April 11, 2022

 社内パッケージの再利用にSatisを使っている話.pdf

PHPerKaigi2022

kin29

April 11, 2022
Tweet

More Decks by kin29

Other Decks in Programming

Transcript

  1. 自己紹介󰢧
 • 林(旧:志賀) 彩乃
 • PHPer 6年
 • Symfony 3年


    • カルテットコミュニケーションズ 3年(産休育休1年含む)
 • 子育て中(1歳半息子)
 Twitter: @kin29ma_n / GitHub: @kin29

  2. quartetcom/repository を使いたい人 composer requireできる + "repositories": { + "quartetcom/repository": {

    + "type": "vcs", + "url": "https://github.com/quartetcom/repository.git" + } + } composer.json composer.jsonのrepositoriesに追加すればcomposer requireできる!
 
 $ composer require quartetcom/repository quartetcom/repository (packagistに未登録)
  3. quartetcom/repo1~3 を使いたい人 "repositories": { "quartetcom/repo1": { "type": "vcs", "url": "https://github.com/quartetcom/repo1.git"

    }, + "quartetcom/repo2": { + "type": "vcs", + "url": "https://github.com/quartetcom/repo2.git" + }, } composer.json quartetcom/repo1 (packagistに未登録) quartetcom/repo2 $ composer require $ composer require
  4. quartetcom/repo1~3 を使いたい人 "repositories": { "quartetcom/repo1": { "type": "vcs", "url": "https://github.com/quartetcom/repo1.git"

    }, + "quartetcom/repo2": { + "type": "vcs", + "url": "https://github.com/quartetcom/repo2.git" + }, + "quartetcom/repo3": { + "type": "vcs", + "url": "https://github.com/quartetcom/repo3.git" + } } composer.json quartetcom/repo1 (packagistに未登録) quartetcom/repo2 quartetcom/repo3 $ composer require
  5. quartetcom/repo1~3 を使いたい人 quartetcom/repo1 (packagistに未登録) quartetcom/repo2 quartetcom/repo3 $ composer require "repositories":

    { "quartetcom/repo1": { "type": "vcs", "url": "https://github.com/quartetcom/repo1.git" }, + "quartetcom/repo2": { + "type": "vcs", + "url": "https://github.com/quartetcom/repo2.git" + }, + "quartetcom/repo3": { + "type": "vcs", + "url": "https://github.com/quartetcom/repo3.git" + } } composer.json めんどう😓 

  6. { "name": "quartetcom.composer", "homepage": "https://quartetcom/composer", "repositories": [ { "type": "vcs",

    "url": "https://github.com/quartetcom/repo1" }, { "type": "vcs", "url": "https://github.com/quartetcom/repo2" }, { "type": "vcs", "url": "https://github.com/quartetcom/repo3" } ], "require-all": true } satis.json quartetcom/repo1~3 を使いたい人 再利用したいリポジトリ quartetcom/repo1 quartetcom/repo2 quartetcom/repo3 $ composer require + "repositories": { + "quartetcom": { + "type": "composer", + "url": "https://quartetcom/composer" + } + }, composer.json $ vendor/bin/satis build satis.json web/ Scanning packages Wrote packages to docs/p2/quartetcom/repo1.json Wrote packages to docs/p2/quartetcom/repo1~dev.json … Writing packages.json Pruning include directories Writing web view
  7. メリット💡
 • satis.jsonに再利用対象のリポジトリを追加→buildするだけでok󰢏
 • 複数パッケージを一括管理しやすい
 • 一覧画面もいい感じにできる👉
 • Basic認証で制限も可能
 •

    ビルドインwebサーバで無料で簡単にできる
 $ php -S localhost:8888 -t web 
 • GitHub Pagesでも作れました🎉 
 https://kin29.github.io/composer-repository/
 

  8. kin29/repo1 - v0.0.1 - v0.0.2🆕 POST (おまけ)GitHub Actionsでsatis buildを自動化してみた!
 on:

    release: types: [published] jobs: run: | curl --request POST 'https://api.github.com/repos/kin29/coposer-repository/dispatches' \ --header 'Authorization: Bearer ${{secrets.MY_TOKEN}}' \ --header 'Content-Type: application/json' \ --data-raw '{"event_type": "repository-updated"}' kin29/composer-repository on: repository_dispatch: types: [repository-updated] jobs: - name: satis build run: | composer config --global github-oauth.github.com ${{secrets.MY_TOKEN}} vendor/bin/satis build satis.json docs - name: Push build files run: | git remote set-url origin https://github-actions:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPO} git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" if (git diff --shortstat | grep '[0-9]'); then \ git add .; \ git commit -m "👕 Fixed satis build files by github-actions"; \ git push origin HEAD:${GITHUB_REF}; \ fi