BobAnkh / auto-generate-changelog

A Github Action to generate CHANGELOG automatically according to conventional commits. Feel free to contribute!
Apache License 2.0
80 stars 22 forks source link

[bug] Could not create a pr with attribute PULL_REQUEST #101

Closed unknowIfGuestInDream closed 1 year ago

unknowIfGuestInDream commented 1 year ago

Describe the bug

Because of branch protection, I want to modify CHANGELOG.md file by creating pr. But after I set the PULL_REQUEST and BRANCH properties it didn't create successfully.

To Reproduce

NOTE:Self-contained, minimal reproducing samples are extremely helpful and will expedite addressing your issue

Steps to reproduce the behavior:

this is my config.

- uses: BobAnkh/auto-generate-changelog@v1.2.2
  with:
    ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
    PATH: 'CHANGELOG.md'
    COMMIT_MESSAGE: 'docs(changelog): update release notes'
    TYPE: 'feat:Feature,fix:Bug Fixes,refactor:Refactor,perf:Performance Improvements'
    PULL_REQUEST: 'changelog'
    BRANCH: 'master'

Expected behavior

successfully created pr

Screenshots

If applicable, add If applicable, add screenshots to help explain your problem.screenshots to help explain your problem.

Environment

Additional context

Run BobAnkh/auto-generate-changelog@v1.2.2
/usr/bin/docker run --name fca41e4d2d56442499ca349a9d9ca545_90cb8e --label 290506 --workdir /github/workspace --rm -e "INPUT_ACCESS_TOKEN" -e "INPUT_PATH" -e "INPUT_COMMIT_MESSAGE" -e "INPUT_TYPE" -e "INPUT_PULL_REQUEST" -e "INPUT_BRANCH" -e "INPUT_REPO_NAME" -e "INPUT_COMMITTER" -e "INPUT_DEFAULT_SCOPE" -e "INPUT_SUPPRESS_UNSCOPED" -e "INPUT_UNRELEASED_COMMITS" -e "INPUT_REGENERATE_COUNT" -e "INPUT_REPLACE_EMPTY_RELEASE_INFO" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/tlcsdm-common/tlcsdm-common":"/github/workspace" 290506:fca41e4d2d56442499ca349a9d9ca545
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (22.0.4)
Collecting pip
  Downloading pip-22.3.1-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 128.4 MB/s eta 0:00:00
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/site-packages (58.1.0)
Collecting setuptools
  Downloading setuptools-65.6.3-py3-none-any.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 176.5 MB/s eta 0:00:00
Requirement already satisfied: wheel in /usr/local/lib/python3.10/site-packages (0.37.1)
Collecting wheel
  Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: wheel
    Found existing installation: wheel 0.37.1
    Uninstalling wheel-0.37.1:
      Successfully uninstalled wheel-0.37.1
  Attempting uninstall: setuptools
    Found existing installation: setuptools 58.1.0
    Uninstalling setuptools-58.1.0:
      Successfully uninstalled setuptools-58.1.0
  Attempting uninstall: pip
    Found existing installation: pip 22.0.4
    Uninstalling pip-22.0.4:
      Successfully uninstalled pip-22.0.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Successfully installed pip-22.3.1 setuptools-65.6.3 wheel-0.38.4
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting PyGithub==1.55
  Downloading PyGithub-1.55-py3-none-any.whl (291 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 291.7/291.7 kB 57.1 MB/s eta 0:00:00
Collecting PyYAML==6.0
  Downloading PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (682 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 682.2/682.2 kB 206.8 MB/s eta 0:00:00
Collecting tqdm==4.64.0
  Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.4/78.4 kB 160.0 MB/s eta 0:00:00
Collecting pyjwt>=2.0
  Downloading PyJWT-2.6.0-py3-none-any.whl (20 kB)
Collecting pynacl>=1.4.0
  Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux20[14](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:15)_x86_64.manylinux_2_24_x86_64.whl (856 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 149.6 MB/s eta 0:00:00
Collecting deprecated
  Downloading Deprecated-1.2.13-py2.py3-none-any.whl (9.6 kB)
Collecting requests>=2.14.0
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 144.0 MB/s eta 0:00:00
Collecting cffi>=1.4.1
  Downloading cffi-1.[15](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:16).1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.8/441.8 kB 177.1 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2022.9.24-py3-none-any.whl ([16](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:17)1 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 161.1/161.1 kB 147.9 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.13-py2.py3-none-any.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.6/140.6 kB 131.3 MB/s eta 0:00:00
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 133.2 MB/s eta 0:00:00
Collecting wrapt<2,>=1.10
  Downloading wrapt-1.14.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_[17](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:18)_x86_64.manylinux2014_x86_64.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 134.2 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (1[18](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:19) kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 114.9 MB/s eta 0:00:00
Installing collected packages: wrapt, urllib3, tqdm, PyYAML, pyjwt, pycparser, idna, charset-normalizer, certifi, requests, deprecated, cffi, pynacl, PyGithub
Successfully installed PyGithub-1.55 PyYAML-6.0 certifi-[20](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:21)22.9.24 cffi-1.15.1 charset-normalizer-2.1.1 deprecated-1.2.13 idna-3.4 pycparser-2.[21](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:22) pyjwt-2.6.0 pynacl-1.5.0 requests-2.28.1 tqdm-4.64.0 urllib3-1.[26](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:27).13 wrapt-1.14.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Traceback (most recent call last):
[INFO] Regenerate releases: ['v1.4.1', 'v1.4.0']
  File "/main.py", line 659, in <module>
[INFO] All regenerate_releases are generated
[INFO] Update changelog
    main()
  File "/main.py", line 655, in main
    changelog.write_data()
  File "/main.py", line 395, in write_data
    self.repo.update_file(self.path, self.commit_message,
  File "/usr/local/lib/python3.10/site-packages/github/Repository.py", line 2154, in update_file
    headers, data = self._requester.requestJsonAndCheck(
  File "/usr/local/lib/python3.10/site-packages/github/Requester.py", line [35](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:36)3, in requestJsonAndCheck
    return self.__check(
  File "/usr/local/lib/python3.10/site-packages/github/Requester.py", line [37](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:38)8, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: [40](https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3556610411/jobs/5974094716#step:4:41)9 {"message": "Could not update file: 6 of 6 required status checks are expected. Changes must be made through a pull request.", "documentation_url": "https://docs.github.com/articles/about-protected-branches"}
boring-cyborg[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the issue template!

BobAnkh commented 1 year ago

Hey, @unknowIfGuestInDream this is not a bug but a configuration error. See this note 2 in README.md:

NOTES 2: PULL_REQUEST must be used with BRANCH together, both should be provided with a valid branch name if you want to open a pull request. The GA will open a pull request from the BRANCH (head branch) to the PULL_REQUEST (base branch). Leave PULL_REQUEST blank if you don't want to open a pull request.

You should switch your BRANCH and PULL_REQUEST, where BRANCH is where push the file to(a unprotected branch) and it will then open a pull request from BRANCH to PULL_REQUEST(the protected branch).

unknowIfGuestInDream commented 1 year ago

I still failed to switch the value of BRANCH and PULL_REQUEST, the error is 404. Whether the branches of BRANCH and PULL_REQUEST must exist? If I only have the master branch, I can't submit pr to modify the changelog?

BobAnkh commented 1 year ago

I still failed to switch the value of BRANCH and PULL_REQUEST, the error is 404. Whether the branches of BRANCH and PULL_REQUEST must exist? If I only have the master branch, I can't submit pr to modify the changelog?

You should provide me with the log so that I can debug it. It will create a new branch named BRANCH for you to push the changelog file. The target branch PULL_REQUEST must exist(in your case it is master). See #78 for its original design.

unknowIfGuestInDream commented 1 year ago

log: https://github.com/unknowIfGuestInDream/tlcsdm-common/actions/runs/3583687513/jobs/6029417453 config: https://github.com/unknowIfGuestInDream/tlcsdm-common/blob/30accb76bc1aa4fad7b4e20ccb2e09249109b159/.github/workflows/changelog.yml#L15-L22

BobAnkh commented 1 year ago

I see. This might be an issue relevant to how pygithub implement the fetch next page function(upstream change their check behavior). I have added a ad-hoc solution to master branch, I wonder that whether you can help me test if @master fix your issue?

unknowIfGuestInDream commented 1 year ago

I'm happy to help you with testing and this solved my problem successfully. Thank you very much for your help

BobAnkh commented 1 year ago

Thank you for your test. I will release a new version which includes this fix. See v1.2.3 if you would like to use a fixed release rather than master branch.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue.