Skip to content

Commit 940e142

Browse files
committed
Use the saved output instead of the saved files
1 parent 7a0ba12 commit 940e142

2 files changed

Lines changed: 19 additions & 25 deletions

File tree

action.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,41 +37,38 @@ inputs:
3737
runs:
3838
using: "composite"
3939
steps:
40-
- id: save-importmap-outputs
41-
name: Save importmap outputs
40+
- id: run-importmaps
41+
name: Run importmap audit and outdated
4242
shell: bash
4343
working-directory: ${{ inputs.rails-root }}
4444
run: |
4545
{
46-
echo importmap-audit<<IMPORTMAP_AUDIT_OUTPUT
46+
echo "importmap-audit<<IMPORTMAP_AUDIT_OUTPUT"
4747
bin/importmap audit 2>&1 || true
4848
echo IMPORTMAP_AUDIT_OUTPUT
4949
} >> "$GITHUB_OUTPUT"
5050
5151
{
52-
echo importmap-outdated<<IMPORTMAP_OUTDATED_OUTPUT
52+
echo "importmap-outdated<<IMPORTMAP_OUTDATED_OUTPUT"
5353
bin/importmap outdated 2>&1 || true
5454
echo IMPORTMAP_OUTDATED_OUTPUT
5555
} >> "$GITHUB_OUTPUT"
5656
57-
bin/importmap audit 2>&1 | tee /tmp/importmap-audit.txt || true
58-
bin/importmap outdated 2>&1 | tee /tmp/importmap-outdated.txt || true
59-
6057
- name: Run importmap-update
6158
shell: bash
6259
working-directory: ${{ github.action_path }}
6360
env:
64-
BUNDLE_GEMFILE: ${{ github.action_path }}/Gemfile
65-
RAILS_ROOT: ${{ inputs.rails-root }}
66-
GITHUB_TOKEN: ${{ inputs.github-token }}
67-
GITHUB_REPOSITORY: ${{ github.repository }}
68-
INPUT_CONFIG_FILE: ${{ inputs.config-file }}
69-
IMPORTMAP_BASE_BRANCH: ${{ inputs.base-branch }}
70-
IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }}
71-
IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }}
72-
IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }}
73-
IMPORTMAP_OUTDATED_FILE: ${{ runner.temp }}/importmap-outdated.txt
74-
IMPORTMAP_AUDIT_FILE: ${{ runner.temp }}/importmap-audit.txt
61+
BUNDLE_GEMFILE: ${{ github.action_path }}/Gemfile
62+
RAILS_ROOT: ${{ inputs.rails-root }}
63+
GITHUB_TOKEN: ${{ inputs.github-token }}
64+
GITHUB_REPOSITORY: ${{ github.repository }}
65+
INPUT_CONFIG_FILE: ${{ inputs.config-file }}
66+
IMPORTMAP_BASE_BRANCH: ${{ inputs.base-branch }}
67+
IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }}
68+
IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }}
69+
IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }}
70+
IMPORTMAP_OUTDATED_OUTPUT: ${{ steps.run-importmaps.outputs.importmap-outdated }}
71+
IMPORTMAP_AUDIT_OUTPUT: ${{ steps.run-importmaps.outputs.importmap-audit }}
7572
run: |
7673
bundle install
7774
bundle exec exe/importmap-update 2>&1 | tee "${IMPORTMAP_RUN_LOG:-/dev/null}"

exe/importmap-update

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# IMPORTMAP_DRY_RUN Set to "true" for a no-side-effects run.
1414
# IMPORTMAP_AUTHOR_NAME Git author name for commits.
1515
# IMPORTMAP_AUTHOR_EMAIL Git author email for commits.
16+
# IMPORTMAP_OUTDATED_OUTPUT Output of `bin/importmap outdated`.
17+
# IMPORTMAP_AUDIT_OUTPUT Output of `bin/importmap audit`.
1618

1719
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
1820

@@ -51,9 +53,6 @@ rescue Importmap::Update::Config::ConfigError => e
5153
exit 2
5254
end
5355

54-
outdated_file = ENV.fetch("IMPORTMAP_OUTDATED_FILE")
55-
audit_file = ENV.fetch("IMPORTMAP_AUDIT_FILE")
56-
5756
repo = ENV["GITHUB_REPOSITORY"]
5857
if repo.nil? || repo.empty?
5958
warn "GITHUB_REPOSITORY is not set; refusing to run."
@@ -75,10 +74,8 @@ git = Importmap::Update::GitClient.new(
7574
author_email: ENV.fetch("IMPORTMAP_AUTHOR_EMAIL", "github-actions[bot]@users.noreply.github.com")
7675
)
7776

78-
outdated_output = File.read(outdated_file)
79-
audit_output = File.read(audit_file)
80-
outdated = Importmap::Update::Parsers::OutdatedParser.parse(outdated_output)
81-
vulnerabilities = Importmap::Update::Parsers::AuditParser.parse(audit_output)
77+
outdated = Importmap::Update::Parsers::OutdatedParser.parse(ENV.fetch("IMPORTMAP_OUTDATED_OUTPUT"))
78+
vulnerabilities = Importmap::Update::Parsers::AuditParser.parse(ENV.fetch("IMPORTMAP_AUDIT_OUTPUT"))
8279
plan = Importmap::Update::Planner.new(
8380
outdated: outdated, vulnerabilities: vulnerabilities, config: config
8481
).call

0 commit comments

Comments
 (0)