Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
feat: use gh in composite action (peter-evans#841)
Browse files Browse the repository at this point in the history
* feat: use gh in composite action

* add shell

* syntax

* token name

* input name

* don't build just test

* remove needs build

* remove typescript code

* update approve step

* use artifact to test pr branch

* fix workflow

* sha to branch name

* update readme

* update readme

* remove unnecessary files
  • Loading branch information
peter-evans authored Mar 8, 2023
1 parent 5edc978 commit 51b7924
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 24,343 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "thursday"
labels:
- "dependencies"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "thursday"
open-pull-requests-limit: 1
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
labels:
- "dependencies"

55 changes: 4 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm run lint
- run: npm run test
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- uses: actions/upload-artifact@v3
with:
name: action.yml
Expand All @@ -48,11 +36,6 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ci-test/status-check-base-${{ matrix.target }}
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
with:
Expand All @@ -77,7 +60,7 @@ jobs:
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: ci-test/status-check-branch-${{ matrix.target }}
branch: ci-test/status-check-branch-${{ matrix.target }}-${{ github.sha }}

- name: Enable Pull Request Automerge
uses: ./
Expand All @@ -97,11 +80,6 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ci-test/reviews-base-${{ matrix.target }}
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -137,31 +115,6 @@ jobs:

- name: Auto approve
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/approve-pull-request-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.cpr.outputs.pull-request-number }}

package:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [testWithRequiredStatusChecks, testWithRequiredReviews]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
commit-message: Update distribution
title: Update distribution
body: |
- Updates the distribution for changes on `main`
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-distribution
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 0 additions & 21 deletions .github/workflows/rebase-command.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/slash-command-dispatch.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
lib/
node_modules/

.DS_Store
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

11 changes: 0 additions & 11 deletions .prettierrc.json

This file was deleted.

19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ A GitHub action to [enable auto-merge](https://docs.github.com/en/github/collabo

## Usage

| :exclamation: Using this action is no longer necessary |
|-----------------------------------------------------------|

The same functionality exists in the GitHub CLI. See the documentation [here](https://cli.github.com/manual/gh_pr_merge).
```yml
- name: Enable Pull Request Automerge
run: gh pr merge --merge --auto "1"
env:
GH_TOKEN: ${{ secrets.PAT }}
```
If you prefer to use this action:
```yml
- uses: peter-evans/enable-pull-request-automerge@v2
with:
Expand Down Expand Up @@ -87,10 +99,9 @@ The `if` condition makes sure we don't approve multiple times if the workflow ex
```yml
- name: Auto approve
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: juliangruber/approve-pull-request-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.cpr.outputs.pull-request-number }}
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## License
Expand Down
17 changes: 14 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ inputs:
required: true
merge-method:
description: 'The merge method to use. `merge`, `rebase` or `squash`.'
default: MERGE
default: merge
runs:
using: 'node16'
main: 'dist/index.js'
using: composite
steps:
- name: Lowercase
id: lowercase
shell: bash
run: |
INPUT=${{ inputs.merge-method }}; echo "merge-method=${INPUT,,}" >> $GITHUB_OUTPUT
- name: Enable automerge
shell: bash
run: gh pr merge -R "${{ inputs.repository }}" --${{ steps.lowercase.outputs.merge-method }} --auto "${{ inputs.pull-request-number }}"
env:
GH_TOKEN: ${{ inputs.token }}
branding:
icon: 'git-pull-request'
color: 'gray-dark'
Loading

0 comments on commit 51b7924

Please sign in to comment.