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

added check for push event in main branch #17

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

PrajwolAmatya
Copy link
Collaborator

@PrajwolAmatya PrajwolAmatya commented Feb 6, 2025

Description

While working on this WP https://community.openproject.org/projects/revealjs/work_packages/60571/activity, there was part of code added to throw proper error message and the following check was added while deleting temporary files form temp folder:

bash~ ~if [ "$resp_code" != "204" ]; then~ ~ echo "Error: Failed to delete file $temp_filename."~ ~fi~ ~

Updated:
Actual failure occurred because the regex didn't match in the following code snippet:

commit_subject=$(git log -1 --pretty=format:%s)
  regex='Merge pull request #[0-9]+ from opf/(.+)$'
  [[ $commit_subject =~ $regex ]]

Because of this when a direct commit is pushed in the main branch it tried to delete a temporary file which does not exist resulting in the upload step to fail with following log:

filename=layout-template.pdf
+ '[' push = pull_request ']'
+ delete_temp_pdf
++ git log -1 --pretty=format:%s
+ commit_subject='check files and permissions'
+ regex='Merge pull request #[0-9]+ from opf/(.+)$'
+ [[ check files and permissions =~ Merge pull request #[0-9]+ from opf/(.+)$ ]]
Error: Process completed with exit code 1.

So, added an extra check for the github event, whether the event is an direct commit on the main branch.

@PrajwolAmatya PrajwolAmatya marked this pull request as ready for review February 6, 2025 06:54
@PrajwolAmatya PrajwolAmatya self-assigned this Feb 6, 2025
Copy link
Collaborator

@individual-it individual-it left a comment

Choose a reason for hiding this comment

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

@as-op is the name of the main branch in all repos where this might get used main, or also master or something else?

@PrajwolAmatya
Copy link
Collaborator Author

@as-op is the name of the main branch in all repos where this might get used main, or also master or something else?

Or should we check both main and master branch?
@individual-it @as-op

@as-op
Copy link
Collaborator

as-op commented Feb 6, 2025

@PrajwolAmatya @individual-it In both current use cases, it is main.
But as this might change from use case to use case, IMO would be best if this can be defined in the ENV variables, too.

@PrajwolAmatya PrajwolAmatya force-pushed the add-check-for-direct-commit-push branch from f59b0a5 to 21919a2 Compare February 6, 2025 08:33
@PrajwolAmatya PrajwolAmatya force-pushed the add-check-for-direct-commit-push branch from 21919a2 to 382e4fb Compare February 6, 2025 08:36
@PrajwolAmatya
Copy link
Collaborator Author

I have added an env DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}

@PrajwolAmatya PrajwolAmatya merged commit 363f667 into main Feb 6, 2025
3 checks passed
@PrajwolAmatya PrajwolAmatya deleted the add-check-for-direct-commit-push branch February 6, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants