From 7a0ba12998c00055a2446bbaca7748bfc582b39c Mon Sep 17 00:00:00 2001 From: Neil Carvalho Date: Mon, 25 May 2026 15:09:40 -0300 Subject: [PATCH 1/3] Set up GitHub output --- action.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 8546301..bb3ddf5 100644 --- a/action.yml +++ b/action.yml @@ -37,12 +37,25 @@ inputs: runs: using: "composite" steps: - - name: Save importmap outputs + - id: save-importmap-outputs + name: Save importmap outputs 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 + { + echo importmap-audit<&1 || true + echo IMPORTMAP_AUDIT_OUTPUT + } >> "$GITHUB_OUTPUT" + + { + echo importmap-outdated<&1 || true + echo IMPORTMAP_OUTDATED_OUTPUT + } >> "$GITHUB_OUTPUT" + + bin/importmap audit 2>&1 | tee /tmp/importmap-audit.txt || true + bin/importmap outdated 2>&1 | tee /tmp/importmap-outdated.txt || true - name: Run importmap-update shell: bash From 940e142189dd880e10b04d3d0be5e967df2feb3c Mon Sep 17 00:00:00 2001 From: Neil Carvalho Date: Mon, 25 May 2026 15:13:55 -0300 Subject: [PATCH 2/3] Use the saved output instead of the saved files --- action.yml | 33 +++++++++++++++------------------ exe/importmap-update | 11 ++++------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/action.yml b/action.yml index bb3ddf5..008dfc8 100644 --- a/action.yml +++ b/action.yml @@ -37,41 +37,38 @@ inputs: runs: using: "composite" steps: - - id: save-importmap-outputs - name: Save importmap outputs + - id: run-importmaps + name: Run importmap audit and outdated shell: bash working-directory: ${{ inputs.rails-root }} run: | { - echo importmap-audit<&1 || true echo IMPORTMAP_AUDIT_OUTPUT } >> "$GITHUB_OUTPUT" { - echo importmap-outdated<&1 || true echo IMPORTMAP_OUTDATED_OUTPUT } >> "$GITHUB_OUTPUT" - bin/importmap audit 2>&1 | tee /tmp/importmap-audit.txt || true - bin/importmap outdated 2>&1 | tee /tmp/importmap-outdated.txt || true - - 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 From 2e62bf2da23b4549342995d0b7529aaca5e764ae Mon Sep 17 00:00:00 2001 From: Neil Carvalho Date: Mon, 25 May 2026 16:01:15 -0300 Subject: [PATCH 3/3] Show step summary --- action.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 008dfc8..7a8c79e 100644 --- a/action.yml +++ b/action.yml @@ -38,23 +38,37 @@ runs: using: "composite" steps: - id: run-importmaps - name: Run importmap audit and outdated + name: Find outdated packages shell: bash working-directory: ${{ inputs.rails-root }} run: | + AUDIT_OUTPUT=$(bin/importmap audit 2>&1 || true) + OUTDATED_OUTPUT=$(bin/importmap outdated 2>&1 || true) + + 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<&1 || true - echo IMPORTMAP_AUDIT_OUTPUT + echo 'importmap-audit<> "$GITHUB_OUTPUT" { - echo "importmap-outdated<&1 || true - echo IMPORTMAP_OUTDATED_OUTPUT + echo 'importmap-outdated<> "$GITHUB_OUTPUT" - - name: Run importmap-update + - id: run-importmaps-update + name: Run importmap-update shell: bash working-directory: ${{ github.action_path }} env: