Skip to content

Commit 6ee9232

Browse files
authored
feat: help with reusing the github actions commands (#273)
1 parent 476391c commit 6ee9232

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

.github/workflows/no-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '!aws/auth/**'
1313
- '!buildkite/run/**'
1414
- '!check-dependent-jobs/**'
15+
- '!elastic/github-commands/**'
1516
- '!git/setup/**'
1617
- '!github/backport-active/**'
1718
- '!github/project-add/**'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: test-elastic-github-commands
2+
3+
on:
4+
merge_group: ~
5+
workflow_dispatch: ~
6+
pull_request:
7+
paths:
8+
- '.github/workflows/test-elastic-github-commands.yml'
9+
- 'elastic/github-commands/**'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
pull-requests: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: ./elastic/github-commands

elastic/github-commands/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# <!--name-->elastic/github-commands<!--/name-->
2+
3+
[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Felastic%2Fgithub-commands+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code)
4+
[![test-elastic-github-commands](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-github-commands.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-github-commands.yml)
5+
6+
<!--description-->
7+
Print the supported GitHub commands
8+
<!--/description-->
9+
10+
## Inputs
11+
<!--inputs-->
12+
| Name | Description | Required | Default |
13+
|---------------------|-------------------------------|----------|-----------------------|
14+
| `github-token` | The GitHub access token. | `false` | `${{ github.token }}` |
15+
| `continue-on-error` | Whether to continue on error. | `false` | `true` |
16+
<!--/inputs-->
17+
18+
## Outputs
19+
20+
<!--outputs-->
21+
| Name | Description |
22+
|------|-------------|
23+
<!--/outputs-->
24+
25+
## Usage
26+
27+
<!--usage action="elastic/oblt-actions/**" version="env:VERSION"-->
28+
```yaml
29+
---
30+
name: github-commands-comment
31+
32+
on:
33+
pull_request_target:
34+
types:
35+
- opened
36+
37+
permissions:
38+
contents: read
39+
40+
jobs:
41+
comment:
42+
runs-on: ubuntu-latest
43+
permissions:
44+
pull-requests: write
45+
steps:
46+
- uses: elastic/oblt-actions/elastic/github-commands@v1
47+
48+
```
49+
50+
<!--/usage-->

elastic/github-commands/action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: elastic/github-commands
2+
description: Print the supported GitHub commands
3+
inputs:
4+
github-token:
5+
description: 'The GitHub access token.'
6+
required: false
7+
type: string
8+
default: ${{ github.token }}
9+
continue-on-error:
10+
description: 'Whether to continue on error.'
11+
required: false
12+
type: boolean
13+
default: true
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
19+
continue-on-error: true
20+
with:
21+
github-token: ${{ inputs.github-token }}
22+
script: |
23+
const body = `
24+
### :robot: GitHub comments
25+
26+
<details><summary>Expand to view the GitHub comments</summary>
27+
<p>
28+
29+
Just comment with:
30+
- \`run\` \`docs-build\` : Re-trigger the docs validation. (use unformatted text in the comment!)
31+
</p>
32+
</details>
33+
`.replace(/ +/g, '')
34+
github.rest.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: body
39+
})

0 commit comments

Comments
 (0)