diff --git a/action.yml b/action.yml index 8546301..7a8c79e 100644 --- a/action.yml +++ b/action.yml @@ -37,28 +37,52 @@ inputs: runs: using: "composite" steps: - - name: Save importmap outputs + - id: run-importmaps + name: Find outdated packages shell: bash working-directory: ${{ inputs.rails-root }} run: | - bin/importmap audit 2>&1 | tee "${{ runner.temp }}/importmap-audit.txt" || true - bin/importmap outdated 2>&1 | tee "${{ runner.temp }}/importmap-outdated.txt" || true + AUDIT_OUTPUT=$(bin/importmap audit 2>&1 || true) + OUTDATED_OUTPUT=$(bin/importmap outdated 2>&1 || true) - - name: Run importmap-update + echo "## Importmap Update" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Vulnerabilities" >> $GITHUB_STEP_SUMMARY + + echo "$AUDIT_OUTPUT" >> $GITHUB_STEP_SUMMARY + + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Outdated packages" >> $GITHUB_STEP_SUMMARY + echo "$OUTDATED_OUTPUT" >> $GITHUB_STEP_SUMMARY + + { + echo 'importmap-audit<> "$GITHUB_OUTPUT" + + { + echo 'importmap-outdated<> "$GITHUB_OUTPUT" + + - id: run-importmaps-update + name: Run importmap-update shell: bash working-directory: ${{ github.action_path }} env: - BUNDLE_GEMFILE: ${{ github.action_path }}/Gemfile - RAILS_ROOT: ${{ inputs.rails-root }} - GITHUB_TOKEN: ${{ inputs.github-token }} - GITHUB_REPOSITORY: ${{ github.repository }} - INPUT_CONFIG_FILE: ${{ inputs.config-file }} - IMPORTMAP_BASE_BRANCH: ${{ inputs.base-branch }} - IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }} - IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }} - IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }} - IMPORTMAP_OUTDATED_FILE: ${{ runner.temp }}/importmap-outdated.txt - IMPORTMAP_AUDIT_FILE: ${{ runner.temp }}/importmap-audit.txt + BUNDLE_GEMFILE: ${{ github.action_path }}/Gemfile + RAILS_ROOT: ${{ inputs.rails-root }} + GITHUB_TOKEN: ${{ inputs.github-token }} + GITHUB_REPOSITORY: ${{ github.repository }} + INPUT_CONFIG_FILE: ${{ inputs.config-file }} + IMPORTMAP_BASE_BRANCH: ${{ inputs.base-branch }} + IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }} + IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }} + IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }} + IMPORTMAP_OUTDATED_OUTPUT: ${{ steps.run-importmaps.outputs.importmap-outdated }} + IMPORTMAP_AUDIT_OUTPUT: ${{ steps.run-importmaps.outputs.importmap-audit }} run: | bundle install bundle exec exe/importmap-update 2>&1 | tee "${IMPORTMAP_RUN_LOG:-/dev/null}" diff --git a/exe/importmap-update b/exe/importmap-update index 650bdae..a94213a 100755 --- a/exe/importmap-update +++ b/exe/importmap-update @@ -13,6 +13,8 @@ # IMPORTMAP_DRY_RUN Set to "true" for a no-side-effects run. # IMPORTMAP_AUTHOR_NAME Git author name for commits. # IMPORTMAP_AUTHOR_EMAIL Git author email for commits. +# IMPORTMAP_OUTDATED_OUTPUT Output of `bin/importmap outdated`. +# IMPORTMAP_AUDIT_OUTPUT Output of `bin/importmap audit`. $LOAD_PATH.unshift File.expand_path("../lib", __dir__) @@ -51,9 +53,6 @@ rescue Importmap::Update::Config::ConfigError => e exit 2 end -outdated_file = ENV.fetch("IMPORTMAP_OUTDATED_FILE") -audit_file = ENV.fetch("IMPORTMAP_AUDIT_FILE") - repo = ENV["GITHUB_REPOSITORY"] if repo.nil? || repo.empty? warn "GITHUB_REPOSITORY is not set; refusing to run." @@ -75,10 +74,8 @@ git = Importmap::Update::GitClient.new( author_email: ENV.fetch("IMPORTMAP_AUTHOR_EMAIL", "github-actions[bot]@users.noreply.github.com") ) -outdated_output = File.read(outdated_file) -audit_output = File.read(audit_file) -outdated = Importmap::Update::Parsers::OutdatedParser.parse(outdated_output) -vulnerabilities = Importmap::Update::Parsers::AuditParser.parse(audit_output) +outdated = Importmap::Update::Parsers::OutdatedParser.parse(ENV.fetch("IMPORTMAP_OUTDATED_OUTPUT")) +vulnerabilities = Importmap::Update::Parsers::AuditParser.parse(ENV.fetch("IMPORTMAP_AUDIT_OUTPUT")) plan = Importmap::Update::Planner.new( outdated: outdated, vulnerabilities: vulnerabilities, config: config ).call