Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 39 additions & 15 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<IMPORTMAP_AUDIT_OUTPUT'
echo "$AUDIT_OUTPUT"
echo 'IMPORTMAP_AUDIT_OUTPUT'
} >> "$GITHUB_OUTPUT"

{
echo 'importmap-outdated<<IMPORTMAP_OUTDATED_OUTPUT'
echo "$OUTDATED_OUTPUT"
echo 'IMPORTMAP_OUTDATED_OUTPUT'
} >> "$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}"
11 changes: 4 additions & 7 deletions exe/importmap-update
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down