Skip to content

Commit

Permalink
fixes for file detection and node version update
Browse files Browse the repository at this point in the history
  • Loading branch information
milliondreams committed Feb 24, 2024
1 parent 85f86f5 commit 99bbe8c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ inputs:
description: 'Ghost Admin API Key'
required: true
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'

17 changes: 5 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ async function main() {
* @param {string} extension - The file extension to filter the results by.
* @returns {string} - The command string.
*/
function getLatestFileCommand(filter, extension) {
return `git diff-tree --no-commit-id --name-only HEAD -r --diff-filter='${filter}' | grep '${extension}'`;
function getLatestFileCommand(extension) {
return `git diff-tree --no-commit-id --name-only HEAD -r --diff-filter=AM | grep '${extension}'`;
}

/**
* Executes a command to find the latest file with a specific extension in the Git repository.
*/
function executeLatestFileCommand(filter, extension) {
const command = getLatestFileCommand(filter, extension);
function executeLatestFileCommand(extension) {
const command = getLatestFileCommand(extension);
console.log('Executing command:', command); // Debug log
return execSync(command).toString().trim();
}
Expand All @@ -109,14 +109,7 @@ function getLatestFile(extension) {
// Show git log
console.log("Git log:\n", execSync('git log --oneline -n 5').toString());

let latestFile;

try {
latestFile = executeLatestFileCommand('A', extension);
} catch (error) {
console.log(`No added '${extension}' file found with error:`, error);
latestFile = executeLatestFileCommand('M', extension);
}
let latestFile = executeLatestFileCommand('A', extension);

console.log('Found file:', latestFile); // Debug log
return latestFile || null;
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


"@tryghost/admin-api@^1.13.10":
version "1.13.10"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api/-/admin-api-1.13.10.tgz#dd9298c7ca04db13be8383880122ba33d4c3b5c6"
integrity sha512-1egCY+QrjV6oNIYFdNFTyO+r4YLwMzq5ScunRghaYdy6AbiJRkKwCbnOtl2H2NLE4r2dTfMEgmhOYn72KspPlw==
version "1.13.11"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api/-/admin-api-1.13.11.tgz#c66c386ed1545311b29175826446558ec46ad183"
integrity sha512-8orRjijkK7tOZ6lx0KZzl/L45RfUUwwCK8TASgLUIGLysLEf/nOQoxKp5jOAlGfUI7rEu7ucVK1KKNles2+dbA==
dependencies:
axios "^1.0.0"
form-data "^4.0.0"
Expand All @@ -27,11 +27,11 @@ asynckit@^0.4.0:
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.0.0:
version "1.6.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.15.0"
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

Expand Down Expand Up @@ -64,10 +64,10 @@ entities@~3.0.1:
resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4"
integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==

follow-redirects@^1.15.0:
version "1.15.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==
follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

form-data@^4.0.0:
version "4.0.0"
Expand Down Expand Up @@ -204,9 +204,9 @@ safe-buffer@^5.0.1:
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
version "7.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
dependencies:
lru-cache "^6.0.0"

Expand Down

0 comments on commit 99bbe8c

Please sign in to comment.