mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-12-07 14:09:47 +00:00
Allows referencing the outputs of previously executed jobs in the `runs-on` field directly by a `${{ needs.some-job.outputs.some-output }}`, and also *indirectly* through the job's `strategy.matrix`. At its most complicated, supports a workflow with dynamic matrices like this:
```yaml
jobs:
define-matrix:
runs-on: docker
outputs:
array-value: ${{ steps.define.outputs.array }}
steps:
- id: define
run: |
echo 'array=["debian-bookworm", "debian-trixie"]' >> "$FORGEJO_OUTPUT"
runs-on-dynamic-matrix:
needs: define-matrix
strategy:
matrix:
my-runners: ${{ fromJSON(needs.define-matrix.outputs.array-value) }}
runs-on: ${{ matrix.my-runners }}
steps:
- run: uname -a
```
## Checklist
The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).
### Tests
- I added test coverage for Go changes...
- [x] in their respective `*_test.go` for unit tests.
- [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
- [ ] in `web_src/js/*.test.js` if it can be unit tested.
- [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).
### Documentation
- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.
- Documentation already (incorrectly) states that `jobs.<job-id>.runs-on` can access the `needs` context. 😛 https://forgejo.org/docs/latest/user/actions/reference/#availability
### Release notes
- [ ] I do not want this change to show in the release notes.
- [x] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.
<!--start release-notes-assistant-->
## Release notes
<!--URL:https://codeberg.org/forgejo/forgejo-->
- Features
- [PR](https://codeberg.org/forgejo/forgejo/pulls/10308): <!--number 10308 --><!--line 0 --><!--description ZmVhdChhY3Rpb25zKTogc3VwcG9ydCByZWZlcmVuY2luZyBgJHt7IG5lZWRzLi4uIH19YCB2YXJpYWJsZXMgaW4gYHJ1bnMtb25g-->feat(actions): support referencing `${{ needs... }}` variables in `runs-on`<!--description-->
<!--end release-notes-assistant-->
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10308
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
598 lines
12 KiB
YAML
598 lines
12 KiB
YAML
-
|
|
id: 600
|
|
run_id: 900
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
started: 1683636528
|
|
needs: '["job1", "job2"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: red
|
|
|
|
-
|
|
id: 601
|
|
run_id: 901
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: ${{ fromJSON(needs.define-matrix.outputs.colors) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 602
|
|
run_id: 901
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 100
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 603
|
|
run_id: 902
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: ${{ fromJSON(needs.define-matrix.outputs.colors) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 604
|
|
run_id: 902
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 100
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 605
|
|
run_id: 903
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix-1"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: ${{ fromJSON(needs.define-matrix-1.outputs.colors) }}
|
|
brightness: ${{ fromJSON(needs.define-matrix-2.outputs.colors) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 606
|
|
run_id: 903
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix-1
|
|
attempt: 0
|
|
job_id: define-matrix-1
|
|
task_id: 100
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 607
|
|
run_id: 904
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: ${{ fromJSON(needs.define-matrix.outputs.colors) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 608
|
|
run_id: 904
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 101
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 609
|
|
run_id: 905
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
run-tests:
|
|
name: run-tests (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
datacenter: ${{ fromJSON(needs.define-matrix.outputs.datacenters) }}
|
|
node: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
|
|
pg: ${{ fromJSON(needs.define-matrix.outputs.pg_version) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 610
|
|
run_id: 905
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 102
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 611
|
|
run_id: 906
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
run-tests:
|
|
name: run-tests (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.define-matrix.outputs.entire-matrix) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 612
|
|
run_id: 906
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 103
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 613
|
|
run_id: 907
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on": [push]
|
|
jobs:
|
|
scalar-job:
|
|
name: scalar-job (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: |
|
|
set -x
|
|
[ "${{ matrix.scalar }}" = "scalar value" ] || [ "${{ matrix.scalar }}" = "hard-coded value" ] || exit 1
|
|
strategy:
|
|
matrix:
|
|
scalar:
|
|
- "${{ needs.define-matrix.outputs.scalar-value }}"
|
|
- hard-coded value
|
|
incomplete_matrix: true
|
|
|
|
-
|
|
id: 614
|
|
run_id: 907
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 104
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 615
|
|
run_id: 908
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: job_1
|
|
attempt: 0
|
|
job_id: job_1
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix-1"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
produce-artifacts:
|
|
name: produce-artifacts (incomplete matrix)
|
|
runs-on: docker
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
color: ${{ fromJSON(needs.define-matrix-1.outputs.colours-intentional-mistake) }}
|
|
incomplete_matrix: true
|
|
-
|
|
id: 616
|
|
run_id: 908
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix-1
|
|
attempt: 0
|
|
job_id: define-matrix-1
|
|
task_id: 100
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 617
|
|
run_id: 909
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-runs-on"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on
|
|
runs-on: ${{ needs.define-runs-on.outputs.run-on-this }}
|
|
steps:
|
|
- run: echo "OK!"
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 618
|
|
run_id: 909
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-runs-on
|
|
attempt: 0
|
|
job_id: define-runs-on
|
|
task_id: 105
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 619
|
|
run_id: 910
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-matrix"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on (incomplete matrix)
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.define-matrix.outputs.entire-matrix) }}
|
|
runs-on: node-${{ matrix.node }}
|
|
steps:
|
|
- run: echo "OK!"
|
|
incomplete_matrix: true
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 620
|
|
run_id: 910
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-matrix
|
|
attempt: 0
|
|
job_id: define-matrix
|
|
task_id: 106
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 621
|
|
run_id: 911
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-runs-on"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on
|
|
runs-on:
|
|
- datacenter-alpha
|
|
- ${{ needs.define-runs-on.outputs.run-on-this }}
|
|
- node-27.x
|
|
steps:
|
|
- run: echo "OK!"
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 622
|
|
run_id: 911
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-runs-on
|
|
attempt: 0
|
|
job_id: define-runs-on
|
|
task_id: 107
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 623
|
|
run_id: 912
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-runs-on", "another-needs"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on
|
|
runs-on: ${{ needs.oops-i-misspelt-the-job-id.outputs.run-on-this }}
|
|
steps:
|
|
- run: echo "OK!"
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 624
|
|
run_id: 912
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-runs-on
|
|
attempt: 0
|
|
job_id: define-runs-on
|
|
task_id: 107
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 625
|
|
run_id: 913
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-runs-on"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on
|
|
runs-on: ${{ needs.define-runs-on.outputs.output-doesnt-exist }}
|
|
steps:
|
|
- run: echo "OK!"
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 626
|
|
run_id: 913
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-runs-on
|
|
attempt: 0
|
|
job_id: define-runs-on
|
|
task_id: 107
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|
|
|
|
-
|
|
id: 627
|
|
run_id: 914
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: consume-runs-on
|
|
attempt: 0
|
|
job_id: consume-runs-on
|
|
task_id: 0
|
|
status: 7 # blocked
|
|
runs_on: '["fedora"]'
|
|
needs: '["define-runs-on"]'
|
|
workflow_payload: |
|
|
"on":
|
|
push:
|
|
jobs:
|
|
consume-runs-on:
|
|
name: consume-runs-on
|
|
runs-on: ${{ matrix.dimension-oops-error }}
|
|
steps:
|
|
- run: echo "OK!"
|
|
strategy:
|
|
matrix:
|
|
dimension1: [ abc, def ]
|
|
incomplete_runs_on: true
|
|
-
|
|
id: 628
|
|
run_id: 914
|
|
repo_id: 63
|
|
owner_id: 2
|
|
commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee
|
|
is_fork_pull_request: 0
|
|
name: define-runs-on
|
|
attempt: 0
|
|
job_id: define-runs-on
|
|
task_id: 107
|
|
status: 1 # success
|
|
runs_on: '["fedora"]'
|