Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a pull request instead of committing directly #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions directory_md/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ runs:
uses: actions/setup-python@v4
with:
python-version: '3.10' # or whatever version you support
Panquesito7 marked this conversation as resolved.
Show resolved Hide resolved
- name: Setup Git configurations
shell: bash
run: |
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Running the formatter
shell: bash
run: |
python build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
- name: Committing changes

git pull || true
- name: Committing and pushing changes
uses: stefanzweifel/git-auto-commit-action@v4
id: commit-push
with:
commit_message: "docs: updating `DIRECTORY.md`"
branch: "directory-${{ github.sha }}"
create_branch: true
- name: Creating and merging the PR
shell: bash
if: steps.commit-push.outputs.changes_detected == 'true'
run: |
git commit -m "chore: update `DIRECTORY.md`" DIRECTORY.md || true
git push origin HEAD:$GITHUB_REF || true
gh pr create --base ${GITHUB_REF##*/} --head directory-${{ github.sha }} --title 'docs: updating `DIRECTORY.md`' --body '`DIRECTORY.md` has been updated (see the diff. for changes).'
gh pr merge --admin --merge --subject 'docs: updating `DIRECTORY.md`' --delete-branch
env:
GH_TOKEN: ${{ github.token }}
Panquesito7 marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 15 additions & 10 deletions formatter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ runs:
steps:
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Setup Git configurations
shell: bash
run: |
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Running the formatter
shell: bash
run: |
filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }}
- name: Committing changes

git pull || true
- name: Committing and pushing changes
uses: stefanzweifel/git-auto-commit-action@v4
id: commit-push
with:
commit_message: "chore: formatting filenames"
branch: "formatting_files-${{ github.sha }}"
create_branch: true
- name: Creating and merging the PR
shell: bash
if: steps.commit-push.outputs.changes_detected == 'true'
run: |
git add ${{ inputs.working-directory }} || true
git commit -m "chore: formatting filenames" || true

git push origin HEAD:$GITHUB_REF || true
gh pr create --base ${GITHUB_REF##*/} --head formatting_files-${{ github.sha }} --title 'chore: formatting filenames' --body 'Formatted filenames (see the diff. for changes).'
gh pr merge --admin --merge --subject 'chore: formatting filenames' --delete-branch
env:
GH_TOKEN: ${{ github.token }}
Comment on lines 36 to +40
Copy link
Member

@tjgurwara99 tjgurwara99 Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW on a personal level, I really think CI checks should help find out the problems for the contributors not fix them so I think fixing the filenames into the correct format automatically means that the contributor really never learns to read the contribution guidelines 😅 - our check should indicate to them that there is a problem with their PR with a comment or something instead of fixing it for them.

EDIT: This argument doesn't apply to the directory.md file since that our problem not the contributors problem 😄

Copy link
Member Author

@Panquesito7 Panquesito7 Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI actually updates the filenames in case the PR creator didn't follow our guidelines.
In this case, it would create a PR to their fork and update it automatically.

But, sometimes GitHub Actions aren't enabled in forks, which then will be updated in our repository in case anything was missed.

Copy link
Member Author

@Panquesito7 Panquesito7 Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I have time to get back to this now, hehe.
I agree with you. Should I edit it so that the action fails if there's anything found, and specify where the error is?

EDIT: I sent you a few messages via Discord about this. Let's discuss it if you like. 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been off discord for a while haha, I'll check again soon 😄