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

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

Merged

Conversation

Sozhan308
Copy link
Contributor

@Sozhan308 Sozhan308 commented Feb 14, 2025

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.

Copy link

@github-actions github-actions bot left a comment

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… Add workflow to enforce PRs to Develop Branch for External Contributo… Feb 14, 2025
@Sozhan308
Copy link
Contributor Author

@omatheusmesmo Kindly review

Copy link
Collaborator

@omatheusmesmo omatheusmesmo left a comment

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
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
Copy link
Contributor Author

Sozhan308 commented Feb 17, 2025

@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
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
2 of 3 checks passed
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 <[email protected]>
Co-authored-by: Wheslley Rimar Bezerra <[email protected]>

* 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 <[email protected]>

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

This reverts commit a61de36.

---------

Co-authored-by: Sozhan Natarajan <[email protected]>
Co-authored-by: Wheslley Rimar Bezerra <[email protected]>
Co-authored-by: Brijesh Thummar <[email protected]>
Co-authored-by: Dumildes Paulo <[email protected]>
@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 <[email protected]>
Co-authored-by: Wheslley Rimar Bezerra <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants