Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GitHub Actionsと GitHub CLIと permissions
Search
ゆきか
November 22, 2024
Technology
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GitHub Actionsと GitHub CLIと permissions
ゆきか
November 22, 2024
More Decks by ゆきか
See All by ゆきか
新潟の鮨のはなし 飯テロver
yukikayuki
0
290
新潟WEBアプリケーション勉強会 Vol.1 LT GraphQL Federation
yukikayuki
0
150
React Hooks勉強会 vol.5
yukikayuki
2
380
Other Decks in Technology
See All in Technology
Kaggleで成長するために意識したこと
prgckwb
2
410
10年目を迎えた「ABEMA」がどのように AI 活用を推進して、AI 駆動開発にシフトしているのか / How ABEMA, entering its 10th year, is promoting the use of AI and shifting toward AI-driven development
miyukki
0
260
そのドキュメント、自動化しませんか?
yuksew
1
300
発表と総括 / Presentations and Summary
ks91
PRO
0
140
AIレビューはどこまで任せられるのか?自動化と人が背負うレビューの境界
sansantech
PRO
3
1.1k
マルチアカウント環境でSecurity Hubの運用、その後どうなった? / SRE NEXT 2026 miniLT会
genda
0
100
Network Firewallやっていき!
news_it_enj
0
170
しぶいSRE: サーバから見えない障害にどう向き合うか。ラストワンマイルのデバッグ実践 / Shibui SRE
kanny
13
6.5k
人を動かすのは時間ではなく、納得感 〜新任EMが入社3ヶ月、組織を2回変えた話〜
kakehashi
PRO
3
270
凡エンジニアがこの先生きのこるためには。〜TypeScript完全に理解したい〜
alchemy1115
2
310
ゴールデンパスは敷いただけでは道にならない ─ 企画部門のエンジニアが技術標準を事業価値に変えるまで
mhrtech
1
210
2年前に削除したPHPクラスが、 ある日突然決済をエラーにした
ykagano
1
280
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
350
YesSQL, Process and Tooling at Scale
rocio
174
15k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Cult of Friendly URLs
andyhume
79
6.9k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
220
4 Signs Your Business is Dying
shpigford
187
22k
Discover your Explorer Soul
emna__ayadi
2
1.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
170
AI: The stuff that nobody shows you
jnunemaker
PRO
8
830
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
190
How STYLIGHT went responsive
nonsquared
100
6.2k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
180
Transcript
GitHub Actionsと GitHub CLIと permissions 2024-11-22 Niigata 5Min Tech #14
@_yukikayuki
自己紹介 KANEDA Takayuki (@_yukikayuki) 株式会社モニクル ソフトウェアエンジニア(Web) + プロダクトSRE 最近メガネを変えた
GitHub ActionsでGitHub CLIを使いたいことあります か?
GitHub Actions(以降GHA)とは > GitHub Actions は、ビルド、テスト、デプロイのパイプラインを自動化でき る継続的インテグレーションと継続的デリバリー (CI/CD) のプラットフォームで す。
リポジトリに対するすべての pull request をビルドしてテストしたり、 マージされた pull request を運用環境にデプロイしたりするワークフローを 作成できます。
利用例 プルリクオープン時のテスト・リント・プレビュー環境へのデプロイ mainブランチへマージした時の本番デプロイ プレビュー環境のクリーニングの定期実行
GitHub CLI(以降ghコマンド)とは > GitHub CLI は、コンピューターのコマンド ラインから GitHub を使用する ためのオープン
ソース ツールです。 コマンドラインから作業しているときは、 GitHub CLI を使用して時間を節約し、コンテキストの切り替えを回避できま す。 できること: Issue と pull request の作成、クローズ、編集、一覧表示、プル リクエストのレビュー、diff、マージなどなど
利用例 リポジトリをクローンする Twitter(現X)で見かけたが、若い人はghコマンドでリポジトリをクローンし ている? ローカルマシンからプルリクを作る gh pr create --title "The
bug is fixed" --body "Everything works again" GHAでリポジトリの情報を取得して何かゴニョゴニョする
GHAでghコマンドを使うには?
jobs: info: runs-on: ubuntu-latest permissions: contents: read pull-requests: read steps:
- uses: actions/checkout@v4 - name: is pr closed shell: bash env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pr_number=${{ github.event.pull_request.number }} is_pr_closed=$(gh pr view $pr_number --json closed -q '.closed') echo $is_pr_closed # false
jobs: info: runs-on: ubuntu-latest permissions: # permissionを指定 contents: read pull-requests:
read steps: - uses: actions/checkout@v4 - name: is pr closed shell: bash env: # 以下の形でGH_TOKENを設定 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pr_number=${{ github.event.pull_request.number }} is_pr_closed=$( gh pr view $pr_number --json closed -q '.closed' ) echo $is_pr_closed # false
permission > 優れたセキュリティ プラクティスとし て、GITHUB_TOKEN に必要最小限の アクセス権を付与することをお勧めしま す。 permissions: actions:
read|write|none attestations: read|write|none checks: read|write|none contents: read|write|none deployments: read|write|none id-token: write|none issues: read|write|none discussions: read|write|none packages: read|write|none pages: read|write|none pull-requests: read|write|none repository-projects: read|write|none security-events: read|write|none statuses: read|write|none
参考URL • https://docs.github.com/ja/actions/about-github-actions/und erstanding-github-actions • https://docs.github.com/ja/github-cli/github-cli/about-github -cli • https://docs.github.com/ja/enterprise-cloud@latest/actions/ writing-workflows/choosing-what-your-workflow-does/contr
olling-permissions-for-github_token