C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

[BUG] CI Worklfow not being able to push changes

Open Panquesito7 opened this issue 2 years ago • 4 comments

Description

The Awesome Workflow makes changes to format files or to change the DIRECTORY.md, and then pushes the changes to the master branch. However, that branch is a protected branch, which means only administrators or certain permitted users can make changes without creating a PR. AFAIK, GitHub Actions cannot be given permissions.

https://github.com/TheAlgorithms/C/actions/runs/3728181169/jobs/6322964878#step:11:19 https://github.com/orgs/community/discussions/25305

Expected behavior

The CI should normally push the changes.

Actual behavior

The CI cannot push any changes to the master branch.

Steps to reproduce

No response

Context

This is very important when updating the DIRECTORY.md file, when formatting files, etc.. Without these, the files may be unformatted or have filenames that do not follow our guidelines and other stuff that the CI takes care of.

Additional information

No response

Panquesito7 avatar Dec 21 '22 16:12 Panquesito7

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 21 '23 00:01 github-actions[bot]

I'm not quite knowledgeable in CI but I've seen the algorithms/python update their DIRECTORY.md file using a CI. I think they are using a GitHub secret token to push things to the directory file i am not sure. I have also seen pre-commit also manage to push changes into the current pull request. I'll do some more researching and I'll let you know how it goes. Hope this helps 🙂 Maybe something like this might just work:

-name: Commit and push changes
         run: |
           git diff DIRECTORY.md
           git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
           git remote set-url origin https://x-access-token:[email protected]/$GITHUB_REPOSITORY
           git push origin HEAD:refs/heads/main --tags
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

realstealthninja avatar Apr 27 '23 04:04 realstealthninja

Thanks. @tjgurwara99 and I are working on this.

Panquesito7 avatar Apr 27 '23 16:04 Panquesito7

Happy to help! Best of luck 🙂

realstealthninja avatar Apr 27 '23 17:04 realstealthninja