diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index f214e58..d717184 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -159,12 +159,12 @@ jobs: contents: read steps: - uses: actions/checkout@v4 - - uses: ./job-name/ - id: job-name + - uses: ./job-context/ + id: job-context - name: Matches expected name run: '[[ "${output}" == "${expected}" ]] || exit 1' env: - output: ${{ steps.job-name.outputs.job-name }} + output: ${{ steps.job-context.outputs.job-name }} expected: "Job Name" test-job-name-matrix: @@ -186,12 +186,12 @@ jobs: - "2.0" steps: - uses: actions/checkout@v4 - - uses: ./job-name/ - id: job-name + - uses: ./job-context/ + id: job-context - name: Matches expected name run: '[[ "${output}" == "${expected}" ]] || exit 1' env: - output: ${{ steps.job-name.outputs.job-name }} + output: ${{ steps.job-context.outputs.job-name }} expected: "Job Name (${{ matrix.build.name }}, ${{ matrix.build.repo }}, ${{ matrix.version }})" - name: Matches GitHub API name run: | @@ -204,7 +204,7 @@ jobs: GH_TOKEN: ${{ github.token }} run_id: ${{ github.run_id }} run_attempt: ${{ github.run_attempt }} - job_name: ${{ steps.job-name.outputs.job-name }} + job_name: ${{ steps.job-context.outputs.job-name }} test-job-name-matrix-expr: # TODO: Using `github.job` with any expressions results in it being empty @@ -221,12 +221,12 @@ jobs: - 2 steps: - uses: actions/checkout@v4 - - uses: ./job-name/ - id: job-name + - uses: ./job-context/ + id: job-context - name: Matches expected name run: '[[ "${output}" == "${expected}" ]] || exit 1' env: - output: ${{ steps.job-name.outputs.job-name }} + output: ${{ steps.job-context.outputs.job-name }} expected: ${{ github.event_name }} - - ${{ matrix.index }} - ${{ strategy.job-index }} - name: Matches GitHub API name run: | @@ -239,4 +239,33 @@ jobs: GH_TOKEN: ${{ github.token }} run_id: ${{ github.run_id }} run_attempt: ${{ github.run_attempt }} - job_name: ${{ steps.job-name.outputs.job-name }} + job_name: ${{ steps.job-context.outputs.job-name }} + + test-job-name-ambiguous: + name: ${{ github.job }} + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + strategy: + fail-fast: false + matrix: + index: + - 1 + - 2 + steps: + - uses: actions/checkout@v4 + - uses: ./job-context/ + id: job-context + - name: Matches expected name + run: '[[ "${output}" == "${expected}" ]] || exit 1' + env: + output: ${{ steps.job-context.outputs.job-name }} + expected: ${{ github.job }} + - name: Matches GitHub API name + run: | + [[ $(jq length <<<"${job_ids}") -eq 2 ]] || exit 1 + [[ -z "${job_id}" ]] || exit 1 + env: + job_ids: ${{ steps.job-context.outputs.job-ids }} + job_id: ${{ steps.job-context.outputs.job-id }} diff --git a/job-name/action.yaml b/job-context/action.yaml similarity index 100% rename from job-name/action.yaml rename to job-context/action.yaml