Skip to content

Add workflow to enforce PRs to Develop Branch for External Contributo… - #209

Merged
omatheusmesmo merged 4 commits into
BuildCLI:developfrom
Sozhan308:ci/workflow-enforce-PRs-to-develop
Feb 18, 2025
Merged

Add workflow to enforce PRs to Develop Branch for External Contributo…#209
omatheusmesmo merged 4 commits into
BuildCLI:developfrom
Sozhan308:ci/workflow-enforce-PRs-to-develop

Conversation

@Sozhan308

@Sozhan308 Sozhan308 commented Feb 14, 2025

Copy link
Copy Markdown
Contributor

Fixes #190

Add External PR Branch Enforcer

Adds GitHub Action to automatically redirect external contributors' PRs to the develop branch. Helps maintain consistent branching strategy and improves workflow.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖🎉 Thank you for your contribution! Your pull request has been submitted successfully. A maintainer from the team will review it as soon as possible. We appreciate your support in making this project better!

@Sozhan308 Sozhan308 changed the title #190 Add workflow to enforce PRs to Develop Branch for External Contributo… Feb 14, 2025
@Sozhan308

Copy link
Copy Markdown
Contributor Author

@omatheusmesmo Kindly review

@omatheusmesmo omatheusmesmo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Sozhan308 , hi,

I have been testing this GitHub workflow in the open-source project, and unfortunately, they did not run successfully for the originally proposed issue. I would like to ask which tests you performed and how I should proceed to test properly.

Additionally, I tested the .yml files in a private repository within the same organization, and the error logs will follow.

Thank you in advance for your help and collaboration.

@omatheusmesmo

Copy link
Copy Markdown
Collaborator

image

##[debug]Evaluating condition for step: 'Check PR target branch'
##[debug]Evaluating: (success() && (github.event.pull_request.base.ref != 'develop') && (github.event.pull_request.author_association != 'OWNER') && (github.event.pull_request.author_association != 'MEMBER'))
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating Index:
##[debug]............Evaluating github:
##[debug]............=> Object
##[debug]............Evaluating String:
##[debug]............=> 'event'
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'pull_request'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'base'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'ref'
##[debug]....=> 'main'
##[debug]....Evaluating String:
##[debug]....=> 'develop'
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating github:
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'event'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'pull_request'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'author_association'
##[debug]....=> 'CONTRIBUTOR'
##[debug]....Evaluating String:
##[debug]....=> 'OWNER'
##[debug]..=> true
##[debug]..Evaluating NotEqual:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating github:
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'event'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'pull_request'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'author_association'
##[debug]....=> 'CONTRIBUTOR'
##[debug]....Evaluating String:
##[debug]....=> 'MEMBER'
##[debug]..=> true
##[debug]=> true
##[debug]Expanded: (true && ('main' != 'develop') && ('CONTRIBUTOR' != 'OWNER') && ('CONTRIBUTOR' != 'MEMBER'))
##[debug]Result: true
##[debug]Starting: Check PR target branch
##[debug]Loading inputs
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: (runner.debug == '1')
##[debug]Evaluating Equal:
##[debug]..Evaluating Index:
##[debug]....Evaluating runner:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'debug'
##[debug]..=> '1'
##[debug]..Evaluating String:
##[debug]..=> '1'
##[debug]=> true
##[debug]Expanded: ('1' == '1')
##[debug]Result: true
##[debug]Loading env
Run actions/github-script@v6
request {
  method: 'POST',
  baseUrl: 'https://api.github.com',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/[2](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:2)0.18.0 (linux; x64)'
  },
  mediaType: { format: '', previews: [] },
  request: {
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 44[3](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:3),
      protocol: 'https:',
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype] {},
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: true,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 0,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false
    },
    hook: [Function: bound bound register]
  },
  url: '/repos/{owner}/{repo}/issues/{issue_number}/comments',
  owner: 'BuildCLI',
  issue_number: 11,
  body: '🤖 Attention! Always use the develop branch for your PRs instead of main.'
}
RequestError [HttpError]: Not Found
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:68[4](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:4)2:21
    at process.processTicksAndRejections (node:internal/process/task_queues:9[5](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:5):5)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v[6](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:6)/dist/index.js:15143:16), <anonymous>:6:1)
    at async main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:20) {
  status: 404,
  response: {
    url: 'https://api.github.com/repos/BuildCLI//issues/11/comments',
    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-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Sun, 16 Feb 2025 11:02:49 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-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '3441:3423A1:50[7](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:7)C7F6:A3640BE:67B1C5D9',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4999',
      'x-ratelimit-reset': '1739707369',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '1',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest',
      status: '404'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/BuildCLI//issues/11/comments',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/20.1[8](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:8).0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"body":"🤖 Attention! Always use the develop branch for your PRs instead of main."}',
    request: { agent: [Agent], hook: [Function: bound bound register] }
  }
}
POST /repos/BuildCLI//issues/[11](https://github.com/BuildCLI/teste_actions/actions/runs/13353918059/job/37295078494#step:2:11)/comments - 404 in 227ms
Error: Unhandled error: HttpError: Not Found
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Check PR target branch
@Sozhan308

Sozhan308 commented Feb 17, 2025

Copy link
Copy Markdown
Contributor Author

@omatheusmesmo You are right, there were few issues. Now I have made some adaptions and tested it and it's working Sozhan308#1

image

@omatheusmesmo omatheusmesmo added the github_actions Pull requests that update GitHub Actions code label Feb 18, 2025
@omatheusmesmo

Copy link
Copy Markdown
Collaborator

@Sozhan308 , great job, We really appreciate, thank you! Feel free to take another issue! 😃

@omatheusmesmo
omatheusmesmo merged commit 7f5ac93 into BuildCLI:develop Feb 18, 2025
omatheusmesmo added a commit that referenced this pull request Feb 19, 2025
* Add workflow to enforce PRs to Develop Branch for External Contributo… (#209)

* Add workflow to enforce PRs to Develop Branch for External Contributors (#190)

* Update workflow to check repository owner instead of PR owner #190

---------

Co-authored-by: Matheus Oliveira da Silva <99829531+omatheusmesmo@users.noreply.github.com>
Co-authored-by: Wheslley Rimar Bezerra <wheslley_rimar@hotmail.com>

* Issue Auto-Closing Automation  (#201)

* Issue Auto-Closing Automation

* Added verification on Auto-close issues on PR merge

* updated workflows failing and comment body

* Feature/auto update fixes issue 56 (#224)

* refactor: Create new classes for better readability and use of JGit operations, and remove unnecessary methods.

* feat: class for CLI Interactions such as get confirmation of an action

* refactor: changed class name from 'BuildCLIIntro' to 'BuildCliService'

* feat: created methods to move between directories, copy folder/files and get bin path

* feat: created method updateBuildCLI, changed the name of class to make more sense, created methods to update local repository and generate the jar

* feat: minor adjustments

* fix: Adjustment of correct behavior when users answer 'no' and close scanner

* fix: Adjustment of correct behavior when users answer 'no' and correct if verification for updated status

* fix/ Added Apache Mina SSHD to manage SSH sessions

* Feat/add doctor command (#219)

* feaa: add scan and fix command

* fix: gradle version

* refactor: fix messages

---------

Co-authored-by: Matheus Oliveira da Silva <99829531+omatheusmesmo@users.noreply.github.com>

* Revert "Feat/add doctor command (#219)" (#234)

This reverts commit a61de36.

---------

Co-authored-by: Sozhan Natarajan <sozhan308@gmail.com>
Co-authored-by: Wheslley Rimar Bezerra <wheslley_rimar@hotmail.com>
Co-authored-by: Brijesh Thummar <brijeshthummar02@gmail.com>
Co-authored-by: Dumildes Paulo <72232653+DumiJDev@users.noreply.github.com>
@omatheusmesmo omatheusmesmo mentioned this pull request Feb 21, 2025
omatheusmesmo added a commit that referenced this pull request Feb 23, 2025
#209)

* Add workflow to enforce PRs to Develop Branch for External Contributors (#190)

* Update workflow to check repository owner instead of PR owner #190

---------

Co-authored-by: Matheus Oliveira da Silva <99829531+omatheusmesmo@users.noreply.github.com>
Co-authored-by: Wheslley Rimar Bezerra <wheslley_rimar@hotmail.com>
DumiJDev pushed a commit to DumiJDev/BuildCLI that referenced this pull request Sep 3, 2025
BuildCLI#209)

* Add workflow to enforce PRs to Develop Branch for External Contributors (BuildCLI#190)

* Update workflow to check repository owner instead of PR owner BuildCLI#190

---------

Co-authored-by: Matheus Oliveira da Silva <99829531+omatheusmesmo@users.noreply.github.com>
Co-authored-by: Wheslley Rimar Bezerra <wheslley_rimar@hotmail.com>
DumiJDev pushed a commit to DumiJDev/BuildCLI that referenced this pull request Sep 3, 2025
BuildCLI#209)

* Add workflow to enforce PRs to Develop Branch for External Contributors (BuildCLI#190)

* Update workflow to check repository owner instead of PR owner BuildCLI#190

---------

Co-authored-by: Matheus Oliveira da Silva <99829531+omatheusmesmo@users.noreply.github.com>
Co-authored-by: Wheslley Rimar Bezerra <wheslley_rimar@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

3 participants