Skip to content

Commit

Permalink
fix: use GITHUB_EVENT_PATH instead of REST API to get repo info (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jul 17, 2023
1 parent 80a5c23 commit 909a57b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v5.1.1] - 2023-07-17
### Fixed
- Use `GITHUB_EVENT_PATH` to get extra repo info
(instead of GitHub REST API, which is flaky).

## [v5.1.0] - 2023-07-13
### Added
- Ability to test a local `luarocks install`, without uploading to luarocks.org
Expand Down
1 change: 1 addition & 0 deletions bin/luarocks-tag-release-action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ local args = {
upload = not is_pull_request,
license = license_input ~= '' and license_input or nil,
luarocks_test_interpreters = test_interpreters,
github_event_path = getenv_or_err('GITHUB_EVENT_PATH'),
}
table.insert(args.dependencies, 1, 'lua >= 5.1')

Expand Down
11 changes: 8 additions & 3 deletions lua/luarocks-tag-release.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
---@field upload boolean Whether to upload to LuaRocks.
---@field license string|nil License SPDX ID (optional).
---@field luarocks_test_interpreters lua_interpreter[]
---@field github_event_path string|nil The path to the file on the runner that contains the full event webhook payload. For example, /github/workflow/event.json.

---@param package_name string
---@param package_version string
Expand Down Expand Up @@ -162,10 +163,14 @@ local function luarocks_tag_release(package_name, package_version, specrev, args
local repo_url = args.github_server_url .. '/' .. args.github_repo
local homepage = repo_url
local license
local repo_info_str, _ =
execute('curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/' .. args.github_repo, print)
local github_event_data = args.github_event_path and read_file(args.github_event_path)
local json = require('dkjson')
local repo_meta = repo_info_str and repo_info_str ~= '' and json.decode(repo_info_str)
local github_event_tbl = github_event_data and json.decode(github_event_data)
local repo_meta = github_event_tbl
and (
github_event_tbl.pull_request and github_event_tbl.pull_request.head and github_event_tbl.pull_request.head.repo
or github_event_tbl.repository
)
if repo_meta then
local repo_license = repo_meta.license or repo_meta.source and repo_meta.source.license
if args.license then
Expand Down

0 comments on commit 909a57b

Please sign in to comment.