Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Prevent dependabot PRs from running a docs preview #747

Merged
merged 4 commits into from
Jun 8, 2022

Conversation

krysal
Copy link
Member

@krysal krysal commented Jun 3, 2022

Fixes

Fixes #746 by @AetherUnbound

Description

This should prevent the job to run on dependabot's PRs according to: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#restrictions-on-repository-forks

Testing Instructions

Merge and rebase an ask dependabot to rebase one PR to see if it works.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • [N/A] I added or updated tests for the changes I made (if applicable).
  • [N/A] I added or updated documentation (if applicable).
  • [N/A] I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@krysal krysal requested a review from a team as a code owner June 3, 2022 15:55
@krysal krysal requested review from obulat and stacimc June 3, 2022 15:55
@openverse-bot openverse-bot added 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🤖 aspect: dx Concerns developers' experience with the codebase labels Jun 3, 2022
@github-actions
Copy link

github-actions bot commented Jun 3, 2022

API Developer Docs Preview: Ready

https://wordpress.github.io/openverse-api/_preview/747

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@stacimc
Copy link
Contributor

stacimc commented Jun 3, 2022

This looks like it will the docs preview from running on PRs from forks, but I'm not sure it will work for dependabot 🤔 The docs seem to indicate that dependabot PRs are treated as though they came from a fork, but they aren't actually:

Starting March 1st, 2021 workflow runs that are triggered by Dependabot from push, pull_request, pull_request_review, or pull_request_review_comment events will be treated as if they were opened from a repository fork.

Maybe something like this would work?

@krysal
Copy link
Member Author

krysal commented Jun 4, 2022

Starting March 1st, 2021 workflow runs that are triggered by Dependabot from push, pull_request, pull_request_review, or pull_request_review_comment events will be treated as if they were opened from a repository fork.

Where is this coming from?

I added the explicit exclusion for depentabot to be extra sure anyway. Thanks for the handy reference!

@krysal krysal force-pushed the fix/docs-preview-job branch from d05d953 to 2d7bd70 Compare June 4, 2022 01:24
@@ -255,7 +255,8 @@ jobs:
publish-docs:
name: Publish developer docs
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'WordPress/openverse-api'
# Check if the event is not triggered by a fork or dependabot
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != "dependabot[bot]"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm worried that this won't run if the PR is pushed to (since it's referencing event.pull_request vs event_name == 'push'. Do you know if there might be a way to test it? We may just want to add github.actor != "dependabot[bot]" to the end of the existing conditional.

@stacimc
Copy link
Contributor

stacimc commented Jun 6, 2022

Starting March 1st, 2021 workflow runs that are triggered by Dependabot from push, pull_request, pull_request_review, or pull_request_review_comment events will be treated as if they were opened from a repository fork.

Where is this coming from?

Sorry, this is coming from the github.blog announcement linked in the issue.

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

LGTM

@AetherUnbound AetherUnbound merged commit 5b4c8b9 into main Jun 8, 2022
@AetherUnbound AetherUnbound deleted the fix/docs-preview-job branch June 8, 2022 20:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs preview does not work with dependabot PRs
5 participants