From 79eea5c6654fbfd2a66a094fe07647cf2b7971a5 Mon Sep 17 00:00:00 2001 From: Will Kelly <67284402+wkelly17@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:16:57 -0600 Subject: [PATCH] adjust management of dates 2 --- .github/workflows/addDatesMeta.yml | 27 +++++++++++++++------------ actions/dates/dates.js | 3 +++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/addDatesMeta.yml b/.github/workflows/addDatesMeta.yml index f92e7bd..7773a42 100644 --- a/.github/workflows/addDatesMeta.yml +++ b/.github/workflows/addDatesMeta.yml @@ -14,9 +14,6 @@ jobs: with: fetch-depth: 0 # needed for full meta history - - name: Install jq - run: sudo apt-get update && sudo apt-get install -y jq - - name: Set git config run: | git config --global user.name 'github-actions[bot]' @@ -24,13 +21,25 @@ jobs: git config --global core.quotePath false - name: get inputs for job + # note the herdocs for multiline outputs run: | + # Collect all files all_files=$(git ls-tree -r --name-only HEAD) + echo "all_files<> $GITHUB_ENV + echo "$all_files" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + # Collect modified files files_modified=$(git diff --name-only HEAD~1 HEAD) + echo "files_modified<> $GITHUB_ENV + echo "$files_modified" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + # Read metadata.json existing_meta=$(cat metadata.json) - echo "all_files=$all_files" >> $GITHUB_ENV - echo "files_modified=$files_modified" >> $GITHUB_ENV - echo "existing_meta=$existing_meta" >> $GITHUB_ENV + echo "existing_meta<> $GITHUB_ENV + echo "$existing_meta" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV - name: Run dates.js uses: ./actions/dates with: @@ -38,9 +47,3 @@ jobs: all-files: ${{ env.all_files }} files-modified: ${{ env.files_modified }} existing-meta: ${{ env.existing_meta }} - - - name: Commit if different - run: | - git add metadata.json - git commit -m "Automated Update of metadata.json with latest file dates" || echo "No changes to commit" - git push || echo "No changes to push" diff --git a/actions/dates/dates.js b/actions/dates/dates.js index dcf1d74..4f5a016 100644 --- a/actions/dates/dates.js +++ b/actions/dates/dates.js @@ -13,6 +13,9 @@ async function run() { const metaParsed = JSON.parse(exisitingMetadataJson); //Record const filesModifiedArr = filesModifiedInCommit.split("\n"); const allFilesInGitArr = filesModifiedInCommit.split("\n"); + octokit.log.info( + `Received ${allFilesInGit.length} all files and ${filesModifiedInCommit.length} modified files` + ); const metadataUpdated = Object.entries(allFilesInGitArr).reduce( (acc, [key, value]) => {