From 98fa65d8f6491c1dfd73da38eed97203fe41e5fd Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 22 Mar 2023 23:25:04 +0900 Subject: [PATCH] Switch to composite action --- action.yml | 24 +++++++++++++++++++++--- main.js | 28 ---------------------------- 2 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 main.js diff --git a/action.yml b/action.yml index 4f84a65..cd2aefb 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,7 @@ inputs: have the appropriate version in it. By default, this action will fail if the version tagged is not found in the changelog file. required: false - default: false + default: 'false' title: description: Format of title (variables `$tag`, `$version`, `$prefix`, and any string) required: false @@ -60,10 +60,28 @@ outputs: computed-prefix: description: > The computed prefix, including '-' and 'v' if found. + value: ${{ steps.main.outputs.computed-prefix }} version: description: The version number extracted from the tag. The tag name is a concatenation of computed-prefix and version. + value: ${{ steps.main.outputs.version }} + +# Note: +# - inputs.* should be manually mapped to INPUT_* due to https://github.com/actions/runner/issues/665 +# - Use GITHUB_*/RUNNER_* instead of github.*/runner.* due to https://github.com/actions/runner/issues/2185 runs: - using: node16 - main: main.js + using: composite + steps: + - id: main + run: bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh" + shell: bash + env: + INPUT_CHANGELOG: ${{ inputs.changelog }} + INPUT_ALLOW_MISSING_CHANGELOG: ${{ inputs.allow_missing_changelog }} + INPUT_TITLE: ${{ inputs.title }} + INPUT_DRAFT: ${{ inputs.draft }} + INPUT_BRANCH: ${{ inputs.branch }} + INPUT_PREFIX: ${{ inputs.prefix }} + INPUT_TOKEN: ${{ inputs.token }} + INPUT_REF: ${{ inputs.ref }} diff --git a/main.js b/main.js deleted file mode 100644 index 804c20d..0000000 --- a/main.js +++ /dev/null @@ -1,28 +0,0 @@ -// This is a script that just calls the bash script that does the main -// processing of the action. It works like a composite action that calls -// a single bash script. -// -// This was originally a trick adopted to make bash script-based actions work -// without docker before composite actions were supported. However, due to -// various problems with composite actions, this trick is still needed: -// - https://github.com/actions/runner/issues/665 -// - https://github.com/actions/runner/issues/2185 -// Although there are ways to work around these like cache-cargo-install-action does: -// https://github.com/taiki-e/cache-cargo-install-action/blob/v1.0.1/action.yml#L9-L11 - -const { execFileSync } = require('child_process'); - -function main() { - try { - execFileSync( - 'bash', - ['--noprofile', '--norc', `${__dirname}/main.sh`], - { stdio: 'inherit' } - ); - } catch (e) { - console.log(`::error::${e.message}`); - process.exit(1); - } -} - -main();