Open micahjon opened 3 years ago
I see this exact same error too. Another action that does a similar thing also has the same behavior: https://github.com/jitterbit/get-changed-files/issues/10
Any resolution to the issue?
@shaunaa126 , what we ended up doing is using git diff
to get a list of all the files that been changed/added/removed. Not nearly as granular, but it will reliably diff any two commits.
name: Get changed files
id: getfile
run: |
if [[ is_the_first_deployment ]]; then
export DIFF=$( git diff --name-only origin/name-of-some-branch ${{ github.sha }} )
echo "Diff between origin/name-of-some-branch and ${{ github.sha }} "
else
export DIFF=$( git diff --name-only ${{ github.event.before }} ${{ github.sha }} )
echo "Diff between ${{ github.event.before }} and ${{ github.sha }} "
fi
echo "::set-output name=files::$( echo "$DIFF" | sed ':a;N;$!ba;s/\n/%0A/g' )"
How you set the is_the_first_deployment
flag and branch name to diff off of is up to you. We have a unique use case where we can hard code the branch name.
Later on you can parse this string in JavaScript:
const allFiles = `${{ steps.getfile.outputs.files }}`
.split('\n')
.map(str => str.trim())
.filter(Boolean);
Thank you for this @micahjon
Same error here.
Same error here.
Switched to a working action: jitterbit/get-changed-files@v1
I also got the same error using that action as well: https://github.com/trilom/file-changes-action/issues/116#issuecomment-789951255
Finally got the same error with commitid: 0000000000000000000000000000000000000000
I also got into this and was so confused because it was working on one project but not another one and I found out how to handle it:
It seems the source code is here https://github.com/jitterbit/get-changed-files/blob/master/src/main.ts#L28-L36
The code handles 2 different events from GitHub Actions push
& pull_request
.
on:
push:
branches:
# Push events our default branch
- main
# Push events to branches matching refs/heads/renovate/...
- 'renovate/**'
pull_request:
paths-ignore:
- '*.md'
- 'renovate.json'
It makes sense to me as a new branch does not have a base / reference where it's from, it's "floating" around, it's when creating the PR that the base branch is selected.
A solution could be to always diff on the default branch, another could be to document this ⬆️
Originally posted by @Jolg42 in https://github.com/Ana06/get-changed-files/issues/12#issuecomment-1012311435
I also got into this and was so confused because it was working on one project but not another one and I found out how to handle it:
It seems the source code is here jitterbit/get-changed-files@
master
/src/main.ts#L28-L36 The code handles 2 different events from GitHub Actionspush
&pull_request
.
- When creating a new branch for a PR, push will be triggered immediately before the PR gets created
- The GitHub API / GitHub context base commit is then 0000000000000000000000000000000000000000
- The get-changed-files action needs to have a non 0/empty base commit to be able to diff
- Defining both push (and specify the branches) and pull_request solves the problem Example
on: push: branches: # Push events our default branch - main # Push events to branches matching refs/heads/renovate/... - 'renovate/**' pull_request: paths-ignore: - '*.md' - 'renovate.json'
It makes sense to me as a new branch does not have a base / reference where it's from, it's "floating" around, it's when creating the PR that the base branch is selected.
A solution could be to always diff on the default branch, another could be to document this arrow_up
Originally posted by @Jolg42 in Ana06/get-changed-files#12 (comment)
As you can see in test made above it doesn't work for me setting branches if any git feature workflows are adopted, especially if in you fork a repo and enable GitHub Actions
@davorpa I didn't check in detail, the problem might be similar but different here 🤔
I thought this trilom/file-changes-action
was a fork of https://github.com/jitterbit/get-changed-files but it seems it's not.
I can recommend you to try out https://github.com/Ana06/get-changed-files, it's the one I'm currently using since a few months.
Same error here. Any workaround ?
Is this action supposed to work when deploying a new branch for the first time (ideally diffing against a different branch)? Or does it only compare commits within the same branch?
We're running into an issue where it fails every time we deploy a branch for the first time. Subsequent deploys to the same branch (which is no longer a new branch at that point) work just fine.
Thanks!
undefined Exception: { "error": "404/HttpError", "from": "undefined/Error", "message": "There was an error getting change files for repo:test-repo owner:test-owner base:0000000000000000000000000000000000000000 head:e966d6f2925816a0d97d45fa30b52840cfe3e79f", "payload": { "name": "HttpError", "status": 404, "headers": { "access-control-allow-origin": "*", "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", "connection": "close", "content-encoding": "gzip", "content-security-policy": "default-src 'none'", "content-type": "application/json; charset=utf-8", "date": "Wed, 10 Feb 2021 17:22:47 GMT", "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "server": "GitHub.com", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "transfer-encoding": "chunked", "vary": "Accept-Encoding, Accept, X-Requested-With", "x-content-type-options": "nosniff", "x-frame-options": "deny", "x-github-media-type": "github.v3; format=json", "x-github-request-id": "BBB8:50DF:1FD85:51579:60241667", "x-ratelimit-limit": "1000", "x-ratelimit-remaining": "999", "x-ratelimit-reset": "1612981367", "x-ratelimit-used": "1", "x-xss-protection": "1; mode=block" }, "request": { "method": "GET", "url": "https://api.github.com/repos/test-owner/test-repo/compare/0000000000000000000000000000000000000000...e966d6f2925816a0d97d45fa30b52840cfe3e79f", "headers": { "accept": "application/vnd.github.v3+json", "user-agent": "octokit.js/16.43.1 Node.js/12.13.1 (Linux 4.15; x64)", "authorization": "token [REDACTED]" }, "request": {} }, "documentation_url": "https://docs.github.com/rest/reference/repos#compare-two-commits" } }