LoginSignup
2
1

More than 3 years have passed since last update.

Github Actions内でprivate repoのassetを取得したいとき、これ使っておけば大丈夫だった

Posted at

Github ActionsでCIしたいけど、private repoにあるバイナリをfetchする必要がある。
そのためには、githubのAPIをcurlで叩いてasset idを調べて... みたいなことをしていませんか?

↓ こういうやつ
* https://stackoverflow.com/a/35280061

$ curl -H "Authorization: token YOURGITHUBTOKEN" \
    https://api.github.com/repos/NAME/REPO/releases/latest 
# => "url": "https://api.github.com/repos/NAME/REPO/releases/assets/1275759" # asset idが見つかった!

その場合は、
* https://github.com/marketplace/actions/fetch-github-release-asset

これ使っておけば全く同じことをしてくれるので便利でした。

しかもasset idとか調べなくてよく、ファイル名記載で大丈夫です。

uses: dsaltares/fetch-gh-release-asset@master
with:
  repo: "dsaltares/godot-wild-jam-18" # どのrepoから
  version: "latest" # どのrelease versionの
  file: "plague-linux.zip" # どのファイルを取ってくるか
  target: "subdir/plague-linux.zip" # そのファイルをCIコンテナのどこに置くか(repoからの相対パス)
  token: ${{ secrets.YOUR_TOKEN }} # private repoの場合はアクセス権限がいるのでPersonal Accesss Tokenを指定する

内部のshellで代わりのことをやってくれています。

fetch先がprivate repoの場合はtoken にGithubのPersonal Access Tokenを設定すれば使えます。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1