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

Automate merge Dependabot PRs for tests #416

Merged
merged 3 commits into from
May 10, 2023
Merged

Conversation

miry
Copy link
Collaborator

@miry miry commented Apr 28, 2023

@miry miry requested a review from lucacome April 28, 2023 17:56
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
if: ${{contains(steps.dependabot-metadata.outputs.directory, '/test')}}
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to have this condition on the approve step? Enabling auto-merge doesn't automatically merge the PR until it's approved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added condition to Approve PR as well.

run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

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

IIRC if we use GITHUB_TOKEN it will not trigger the pipeline after merge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used official docs for this https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
I have less expirience with Github actions, so no idea if it works.
Expecting on next dependabot schedule it show errors.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry took me a while to find the doc 🙂 https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow

When you use the repository's GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN, with the exception of workflow_dispatch and repository_dispatch, will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

we need to use a PAT to keep the same behavior, meaning a PR from dependabot merged to master will trigger a pipeline run

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pls correct me if I understand correctly.
The problem, not with merging, but it would not trigger anything on new commits in master branch. In other words, it would ignore checks.

Is that sound right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it should be fine.
Because there is a linear history changes required,
I would assume the checks should not be run twice for the same commit.
Also those changes probably would not require for us to update docker images or other stuff.

Copy link
Member

Choose a reason for hiding this comment

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

The problem, not with merging, but it would not trigger anything on new commits in master branch. In other words, it would ignore checks.

Yep that's right it will not trigger the pipeline on the new commit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the end, because I switched to Autosquash, it actually triggers a new checks for merged commits and it seems it works separatly from Github Actions.

@lucacome
Copy link
Member

We should also enable some checks, on the required jobs, I think without them it won't wait for the workflows to run

@miry
Copy link
Collaborator Author

miry commented Apr 28, 2023

We should also enable some checks, on the required jobs, I think without them it won't wait for the workflows to run

Yep. There is enabled option for protected branch for checks required.

@miry miry changed the title Automate merge Dependabot PRs Automate merge Dependabot PRs for tests Apr 28, 2023
@miry
Copy link
Collaborator Author

miry commented May 5, 2023

@lucacome What do you think if I merge, and we will if it works?

@miry miry enabled auto-merge (squash) May 10, 2023 08:51
@miry miry merged commit b67253d into master May 10, 2023
@miry miry deleted the 416-automerge-dependabot branch May 10, 2023 09:11
@miry
Copy link
Collaborator Author

miry commented May 11, 2023

it was funny experiments and learning for me.

  1. I placed script in wrong folder -> that I fixed later
  2. I used wrong steps name to access metainformation.
  3. Auto merge is not working properly with Require linear history -> It requires me to update the command to use Auto Squash instead.

Learning part:

  1. Github actions are hard to test and debug.
  2. Auto merge feature does not provide any reason about errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants