Skip to content

Commit 1a9f21e

Browse files
committed
CI fix
1 parent e523182 commit 1a9f21e

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

.github/workflows/build-test.yaml

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,47 @@ name: Build & Test
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
workflow_dispatch:
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Check out repository
13-
uses: actions/checkout@v2
14-
15-
- name: Build with ncc
16-
run: |
17-
npm install
18-
npm run build
19-
20-
- name: Invoke echo 1 workflow using this action
21-
uses: ./
22-
with:
23-
workflow: Message Echo 1
24-
token: ${{ secrets.PERSONAL_TOKEN }}
25-
inputs: '{"message": "blah blah"}'
26-
27-
- name: Invoke echo 2 workflow using this action
28-
uses: ./
29-
with:
30-
workflow: echo-2.yaml
31-
token: ${{ secrets.PERSONAL_TOKEN }}
32-
33-
- name: Invoke echo 1 workflow by id
34-
uses: ./
35-
with:
36-
workflow: '1854247'
37-
token: ${{ secrets.PERSONAL_TOKEN }}
38-
inputs: '{"message": "Mango jam"}'
39-
40-
- name: Update repo with build
41-
uses: mikeal/publish-to-github-action@master
42-
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
- name: Check out repository
13+
uses: actions/checkout@v4
14+
15+
- name: Build with ncc
16+
run: |
17+
npm install
18+
npm run build
19+
20+
- name: Invoke echo 1 workflow using this action
21+
uses: ./
22+
with:
23+
workflow: Message Echo 1
24+
inputs: '{"message": "blah blah"}'
25+
26+
- name: Invoke echo 2 workflow using this action
27+
uses: ./
28+
with:
29+
workflow: echo-2.yaml
30+
31+
- name: Invoke echo 1 workflow by id
32+
uses: ./
33+
with:
34+
workflow: "1854247"
35+
inputs: '{"message": "Mango jam"}'
36+
37+
- name: Update repo with build
38+
uses: mikeal/publish-to-github-action@master
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4441

4542
# - name: Invoke external workflow using this action
4643
# uses: ./
4744
# with:
48-
# workflow: Deploy To Kubernetes
45+
# workflow: Deploy To Kubernetes
4946
# repo: benc-uk/dapr-store
5047
# token: ${{ secrets.PERSONAL_TOKEN }}
51-
# ref: master
52-
48+
# ref: master

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ This allows you to chain workflows, the classic use case is have a CI build work
77

88
For details of the `workflow_dispatch` even see [this blog post introducing this type of trigger](https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/)
99

10-
*Note 1.* GitHub now has a native way to chain workflows called "reusable workflows". See the docs on [reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows). This approach is somewhat different from workflow_dispatch but it's worth keeping in mind.
10+
_Note 1._ GitHub now has a native way to chain workflows called "reusable workflows". See the docs on [reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows). This approach is somewhat different from workflow_dispatch but it's worth keeping in mind.
1111

12-
*Note 2.* The GitHub UI will report flows triggered by this action as "manually triggered" even though they have been run programmatically via another workflow and the API.
12+
_Note 2._ The GitHub UI will report flows triggered by this action as "manually triggered" even though they have been run programmatically via another workflow and the API.
1313

14-
*Note 3.* If you want to reference the target workflow by ID, you will need to list them with the following REST API call `curl https://api.github.com/repos/{{owner}}/{{repo}}/actions/workflows -H "Authorization: token {{pat-token}}"`
14+
_Note 3._ If you want to reference the target workflow by ID, you will need to list them with the following REST API call `curl https://api.github.com/repos/{{owner}}/{{repo}}/actions/workflows -H "Authorization: token {{pat-token}}"`
1515

1616
## Action Inputs
1717

1818
### `workflow`
19+
1920
**Required.** The name, filename or ID of the workflow to be triggered and run. All three possibilities are used when looking for the workflow. e.g.
2021

2122
```yaml
@@ -27,26 +28,34 @@ workflow: 1218419
2728
```
2829
2930
### `inputs`
31+
3032
**Optional.** The inputs to pass to the workflow (if any are configured), this must be a JSON encoded string, e.g. `{ "myInput": "foobar" }`
3133

3234
### `ref`
33-
**Optional.** The Git reference used with the triggered workflow run. The reference can be a branch, tag, or a commit SHA. If omitted the context ref of the triggering workflow is used. If you want to trigger on pull requests and run the target workflow in the context of the pull request branch, set the ref to `${{ github.event.pull_request.head.ref }}`.
35+
36+
**Optional.** The Git reference used with the triggered workflow run. The reference can be a branch, tag, or a commit SHA. If omitted the context ref of the triggering workflow is used. If you want to trigger on pull requests and run the target workflow in the context of the pull request branch, set the ref to `${{ github.event.pull_request.head.ref }}`.
3437

3538
### `repo`
39+
3640
**Optional.** The default behavior is to trigger workflows in the same repo as the triggering workflow, if you wish to trigger in another GitHub repo "externally", then provide the owner + repo name with slash between them e.g. `microsoft/vscode`.
3741

38-
- When triggering across repos like this, you **must** provide a `token` (see below), or you will get an *"Resource not accessible by integration"* error.
39-
- If the default branch in the other repo is different from the calling repo, you must provide `ref` input also, or you will get a *"No ref found"* error.
42+
- When triggering across repos like this, you **must** provide a `token` (see below), or you will get an _"Resource not accessible by integration"_ error.
43+
- If the default branch in the other repo is different from the calling repo, you must provide `ref` input also, or you will get a _"No ref found"_ error.
4044

4145
### `token`
42-
**Optional.** By default the standard `github.token`/`GITHUB_TOKEN` will be used and you no longer need to provide your own token here. However when using the `repo` option, you must provide a token here, create a PAT token with repo rights, and pass it here via a secret. This options is also left for backwards compatibility reasons.
4346

47+
**Optional.** By default the standard `github.token`/`GITHUB_TOKEN` will be used and you no longer need to provide your own token here.
48+
49+
**⚠️ IMPORTANT:** When using the `repo` option to call across repos, you **must** provide the token. In order to do so, create a PAT token with repo rights, and pass it here via a secret, e.g. `${{ secrets.MY_TOKEN }}`.
50+
51+
This option is also left for backwards compatibility with older versions where this field was mandatory.
4452

4553
## Action Outputs
46-
This Action emits a single output named `workflowId`.
4754

55+
This Action emits a single output named `workflowId`.
4856

4957
## Example usage
58+
5059
```yaml
5160
- name: Invoke workflow without inputs
5261
uses: benc-uk/workflow-dispatch@v1
@@ -69,4 +78,6 @@ This Action emits a single output named `workflowId`.
6978
workflow: my-workflow.yaml
7079
repo: benc-uk/example
7180
inputs: '{ "message": "blah blah", "something": false }'
81+
# Required when using the `repo` option. Either a PAT or a token generated from the GitHub app or CLI
82+
token: "${{ secrets.MY_TOKEN }}"
7283
```

0 commit comments

Comments
 (0)