-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/add dependabot automation #66
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
base: main
Are you sure you want to change the base?
Changes from all commits
d4992c8
6c81613
a688619
c7aa5fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Dependabot auto-approve | ||
| on: pull_request | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| get-metadata: | ||
| uses: ./.github/workflows/dependabot-metadata.yml | ||
|
|
||
| dependabot: | ||
| runs-on: ubuntu-latest | ||
| needs: get-metadata | ||
| steps: | ||
| - name: Approve a PR | ||
| if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch' | ||
| run: gh pr review --approve "$PR_URL" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Dependabot auto-label | ||
| on: pull_request | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| get-metadata: | ||
| uses: ./.github/workflows/dependabot-metadata.yml | ||
|
|
||
| dependabot: | ||
| runs-on: ubuntu-latest | ||
| needs: get-metadata | ||
| steps: | ||
| - name: Add a label for all production dependencies | ||
| if: needs.get-metadata.outputs.dependency-type == 'direct:production' | ||
| run: gh pr edit "$PR_URL" --add-label "dep:production" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Add a label for all development dependencies | ||
| if: needs.get-metadata.outputs.dependency-type == 'direct:development' | ||
| run: gh pr edit "$PR_URL" --add-label "dep:development" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Add a label for all indirect dependencies | ||
| if: needs.get-metadata.outputs.dependency-type == 'indirect' | ||
| run: gh pr edit "$PR_URL" --add-label "dep:indirect" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||||||||||||||||||||||||
| name: Dependabot auto-merge | ||||||||||||||||||||||||||||||||
| on: pull_request | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| get-metadata: | ||||||||||||||||||||||||||||||||
| uses: ./.github/workflows/dependabot-metadata.yml | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| dependabot: | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| needs: get-metadata | ||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Enable auto-merge for Dependabot PRs | ||||||||||||||||||||||||||||||||
| if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch' | ||||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+17
|
||||||||||||||||||||||||||||||||
| - name: Enable auto-merge for Dependabot PRs | |
| if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch' | |
| - name: Check dependency allowlist | |
| id: allowlist | |
| run: | | |
| ALLOWLIST="lodash,react,express" | |
| DEPENDENCY="${{ needs.get-metadata.outputs.dependency-name }}" | |
| if [[ ",$ALLOWLIST," == *",$DEPENDENCY,"* ]]; then | |
| echo "allowed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "allowed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Enable auto-merge for Dependabot PRs | |
| if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch' && steps.allowlist.outputs.allowed == 'true' && github.event.pull_request.mergeable_state == 'clean' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uniqueck, PRs can't be merge without a success CI build anyway, right?
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,63 @@ | ||||||
| name: Get Dependabot Metadata | ||||||
|
|
||||||
| on: | ||||||
| workflow_call: | ||||||
| inputs: | ||||||
| github-token: | ||||||
| description: 'GitHub token for authentication' | ||||||
| required: false | ||||||
| type: string | ||||||
| default: ${{ github.token }} | ||||||
|
||||||
| default: ${{ github.token }} | |
| default: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable to me
Uh oh!
There was an error while loading. Please reload this page.