-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the option to customize working directory and add PR outputs (#3)
- Loading branch information
Showing
3 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,21 +37,33 @@ jobs: | |
### Action inputs | ||
<!-- BEGIN_ACTION_INPUT_TABLE --> | ||
| NAME | DESCRIPTION | REQUIRED | DEFAULT | | ||
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------| | ||
| `author` | The author name and email address in the format Display Name <[email protected]>. Defaults to the user who triggered the workflow run. | `false` | `${{github.actor}} <${{github.actor}}@users.noreply.github.com>` | | ||
| `commit-message` | The message to use when committing changes. | `false` | `[bot] Bump ${{github.event.repository.name}}` | | ||
| `committer` | The committer name and email address in the format Display Name <[email protected]>. Defaults to the GitHub Actions bot user. | `false` | `GitHub <[email protected]>` | | ||
| `labels` | A comma or newline-separated list of labels. | `false` | `bot` | | ||
| `relevance-filter` | A path filter used to determine if any relevant files where changed as a result of the `update-command`. By default, all changes are considered relevant. | `false` | `- '**'` | | ||
| `repository` | The downstream repository that consumes the library dependency. | `true` | `N/A` | | ||
| `reviewers` | A comma or newline-separated list of reviewers (GitHub usernames) to request a review from. | `false` | `N/A` | | ||
| `team-reviewers` | A comma or newline-separated list of GitHub teams to request a review from. | `false` | `N/A` | | ||
| `title` | The title of the pull request. | `false` | `[bot] Bump ${{github.event.repository.name}}` | | ||
| `token` | Github PAT used to open PRs. This token must have write access against the repository. | `true` | `N/A` | | ||
| `update-command` | The command run from the downstream repo that is used to update the library dependency. | `true` | `N/A` | | ||
| NAME | DESCRIPTION | REQUIRED | DEFAULT | | ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------| | ||
| `author` | The author name and email address in the format Display Name <[email protected]>. Defaults to the user who triggered the workflow run. | `false` | `${{github.actor}} <${{github.actor}}@users.noreply.github.com>` | | ||
| `commit-message` | The message to use when committing changes. | `false` | `[bot] Bump ${{github.event.repository.name}}` | | ||
| `committer` | The committer name and email address in the format Display Name <[email protected]>. Defaults to the GitHub Actions bot user. | `false` | `GitHub <[email protected]>` | | ||
| `labels` | A comma or newline-separated list of labels. | `false` | `bot` | | ||
| `relevance-filter` | A path filter used to determine if any relevant files where changed as a result of the `update-command`. By default, all changes are considered relevant. | `false` | `- '**'` | | ||
| `repository` | The downstream repository that consumes the library dependency. | `true` | `N/A` | | ||
| `reviewers` | A comma or newline-separated list of reviewers (GitHub usernames) to request a review from. | `false` | `N/A` | | ||
| `team-reviewers` | A comma or newline-separated list of GitHub teams to request a review from. | `false` | `N/A` | | ||
| `title` | The title of the pull request. | `false` | `[bot] Bump ${{github.event.repository.name}}` | | ||
| `token` | Github PAT used to open PRs. This token must have write access against the repository. | `true` | `N/A` | | ||
| `update-command` | The command run from the downstream repo that is used to update the library dependency. | `true` | `N/A` | | ||
| `working-directory` | The relative directory in the downstream repo where all commands will run. | `false` | `N/A` | | ||
<!-- END_ACTION_INPUT_TABLE --> | ||
|
||
### Action outputs | ||
|
||
<!-- BEGIN_ACTION_OUTPUT_TABLE --> | ||
| NAME | DESCRIPTION | | ||
|--------------------------|---------------------------------------------------------------------------------------| | ||
| `pull-request-head-sha` | The commit SHA of the pull request branch. | | ||
| `pull-request-number` | The pull request number | | ||
| `pull-request-operation` | The pull request operation performed by the action, `created`, `updated` or `closed`. | | ||
| `pull-request-url` | The URL of the pull request. | | ||
<!-- END_ACTION_OUTPUT_TABLE --> | ||
|
||
## Development | ||
|
||
If you change or add an input, use `./scripts/update-readme.sh` to keep the above **Action inputs** table up to date. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ inputs: | |
update-command: | ||
required: true | ||
description: The command run from the downstream repo that is used to update the library dependency. | ||
working-directory: | ||
required: false | ||
default: "" | ||
description: The relative directory in the downstream repo where all commands will run. | ||
relevance-filter: | ||
required: false | ||
default: "- '**'" | ||
|
@@ -41,6 +45,20 @@ inputs: | |
description: A comma or newline-separated list of labels. | ||
default: bot | ||
|
||
outputs: | ||
pull-request-number: | ||
description: "The pull request number" | ||
value: ${{steps.create-pr.outputs.pull-request-number}} | ||
pull-request-url: | ||
description: "The URL of the pull request." | ||
value: ${{steps.create-pr.outputs.pull-request-url}} | ||
pull-request-operation: | ||
description: "The pull request operation performed by the action, `created`, `updated` or `closed`." | ||
value: ${{steps.create-pr.outputs.pull-request-description}} | ||
pull-request-head-sha: | ||
description: "The commit SHA of the pull request branch." | ||
value: ${{steps.create-pr.outputs.pull-request-head-sha}} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
|
@@ -51,11 +69,22 @@ runs: | |
token: ${{inputs.token}} | ||
path: ${{inputs.repository}} | ||
|
||
- name: Set working directory | ||
shell: bash | ||
id: working-dir | ||
run: | | ||
if [ -z "${{inputs.working-directory}}" ] | ||
then | ||
echo "::set-output name=dir::${{inputs.repository}}" | ||
else | ||
echo "::set-output name=dir::${{inputs.repository}}/${{inputs.working-directory}}" | ||
fi | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version-file: ${{inputs.repository}}/go.mod | ||
go-version-file: ${{steps.working-dir.outputs.dir}}/go.mod | ||
cache: true | ||
cache-dependency-path: ${{inputs.repository}}/go.sum | ||
cache-dependency-path: ${{steps.working-dir.outputs.dir}}/go.sum | ||
|
||
- name: Setup git | ||
shell: bash | ||
|
@@ -64,15 +93,15 @@ runs: | |
- name: Run update command | ||
shell: bash | ||
working-directory: ${{inputs.repository}} | ||
working-directory: ${{steps.working-dir.outputs.dir}} | ||
run: ${{inputs.update-command}} | ||
|
||
# If the only files that changed are go.mod, go.sum, and vendor/modules.txt, then it's not worth a PR. | ||
- name: Check if relevant files were changed | ||
uses: dorny/[email protected] | ||
id: changes | ||
with: | ||
working-directory: ${{inputs.repository}} | ||
working-directory: ${{steps.working-dir.outputs.dir}} | ||
base: HEAD | ||
filters: | | ||
relevant: | ||
|
@@ -81,6 +110,7 @@ runs: | |
- name: Create pull request | ||
if: steps.changes.outputs.relevant == 'true' | ||
uses: peter-evans/[email protected] | ||
id: create-pr | ||
with: | ||
branch: bump-${{github.repository}}/patch | ||
path: ${{inputs.repository}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters