From 4a5d18a43e3fc2bd6c57b57259652e571944355e Mon Sep 17 00:00:00 2001 From: himax Date: Fri, 23 May 2025 17:13:17 +0300 Subject: [PATCH 1/4] check payload Signed-off-by: himax --- .github/workflows/step-output.yaml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/step-output.yaml b/.github/workflows/step-output.yaml index 1b74a64..950396b 100644 --- a/.github/workflows/step-output.yaml +++ b/.github/workflows/step-output.yaml @@ -2,12 +2,13 @@ name: Step output on: workflow_dispatch: - pull_request_target: - types: - - opened - - labeled - - reopened - - synchronize + # pull_request_target: + # types: + # - opened + # - labeled + # - reopened + # - synchronize + pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.ref }} @@ -34,9 +35,15 @@ jobs: # id: list_envs # run: env + # - name: Check expressions + # env: + # MY_VAR: ${{ contains(github.event.pull_request.labels.*.name, 'analyze/svace') && true || false }} + # run: | + # echo $MY_VAR + - name: Check expressions env: - MY_VAR: ${{ contains(github.event.pull_request.labels.*.name, 'analyze/svace') && true || false }} + MY_VAR: ${{ github.event.pull_request.number }} run: | echo $MY_VAR From a7f737bb7dcc6120cfee8d6ed8481d543506fd28 Mon Sep 17 00:00:00 2001 From: himax Date: Fri, 23 May 2025 17:18:54 +0300 Subject: [PATCH 2/4] check modules Signed-off-by: himax --- .github/workflows/step-output.yaml | 62 +++++++++++++++++++----------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/step-output.yaml b/.github/workflows/step-output.yaml index 950396b..472d8bb 100644 --- a/.github/workflows/step-output.yaml +++ b/.github/workflows/step-output.yaml @@ -9,37 +9,55 @@ on: # - reopened # - synchronize pull_request: + types: [opened, reopened, synchronize, labeled, unlabeled] + concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.ref }} cancel-in-progress: true jobs: - job1: + set_vars: runs-on: ubuntu-latest + name: Set TAGs + # outputs: + # modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} + # module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} + # runner_type: ${{ steps.modules_module_tag.outputs.RUNNER_TYPE }} steps: - # - name: set output - # id: set-output - # shell: bash - # run: | - # env - # echo "greeting_message=Hello world!" >> $GITHUB_OUTPUT - # echo $GITHUB_OUTPUT - # cat $GITHUB_OUTPUT - - # - name: get output - # run: | - # echo "${{ steps.set-output.outputs.greeting_message }}" - - # - name: list envs - # id: list_envs - # run: env + # - name: Get Pull Request Labels + # id: get-labels + # uses: actions/github-script@v7 + # with: + # script: | + # if (context.eventName === "pull_request" || context.eventName === "pull_request_target" ) { + # const prNumber = context.payload.pull_request.number; + # const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + # owner: context.repo.owner, + # repo: context.repo.repo, + # issue_number: prNumber, + # }); + # return labels.map(label => label.name); + # } else { + # return []; + # } + # result-encoding: string - # - name: Check expressions - # env: - # MY_VAR: ${{ contains(github.event.pull_request.labels.*.name, 'analyze/svace') && true || false }} - # run: | - # echo $MY_VAR + - name: Set vars + id: modules_module_tag + run: | + if [[ "${{ github.ref_name }}" == 'main' ]]; then + MODULES_MODULE_TAG="${{ github.ref_name }}" + elif [[ "${{ github.ref_name }}" =~ ^release-[0-9]+\.[0-9]+ ]]; then + MODULES_MODULE_TAG="${{ github.ref_name }}" + elif [[ -n "${{ github.event.pull_request.number }}" ]]; then + MODULES_MODULE_TAG="pr${{ github.event.pull_request.number }}" + elif [[ -n "${{ github.event.inputs.pr_number }}" ]]; then + MODULES_MODULE_TAG="pr${{ github.event.inputs.pr_number }}" + else + echo "::error title=Module image tag is required::Can't detect module tag from workflow context. Dev build uses branch name as tag for main and release branches, and PR number for builds from pull requests. Check workflow for correctness." + exit 1 + fi - name: Check expressions env: From 4777eb69972179566aa405cc88190350123b8cad Mon Sep 17 00:00:00 2001 From: himax Date: Fri, 23 May 2025 17:19:57 +0300 Subject: [PATCH 3/4] check set vars Signed-off-by: himax --- .github/workflows/step-output.yaml | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/step-output.yaml b/.github/workflows/step-output.yaml index 472d8bb..e390209 100644 --- a/.github/workflows/step-output.yaml +++ b/.github/workflows/step-output.yaml @@ -20,28 +20,28 @@ jobs: set_vars: runs-on: ubuntu-latest name: Set TAGs - # outputs: - # modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} - # module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} - # runner_type: ${{ steps.modules_module_tag.outputs.RUNNER_TYPE }} + outputs: + modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} + module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} + runner_type: ${{ steps.modules_module_tag.outputs.RUNNER_TYPE }} steps: - # - name: Get Pull Request Labels - # id: get-labels - # uses: actions/github-script@v7 - # with: - # script: | - # if (context.eventName === "pull_request" || context.eventName === "pull_request_target" ) { - # const prNumber = context.payload.pull_request.number; - # const { data: labels } = await github.rest.issues.listLabelsOnIssue({ - # owner: context.repo.owner, - # repo: context.repo.repo, - # issue_number: prNumber, - # }); - # return labels.map(label => label.name); - # } else { - # return []; - # } - # result-encoding: string + - name: Get Pull Request Labels + id: get-labels + uses: actions/github-script@v7 + with: + script: | + if (context.eventName === "pull_request" || context.eventName === "pull_request_target" ) { + const prNumber = context.payload.pull_request.number; + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + }); + return labels.map(label => label.name); + } else { + return []; + } + result-encoding: string - name: Set vars id: modules_module_tag From 44c658ca56e41e93869a237ede17fd1a6cc727e6 Mon Sep 17 00:00:00 2001 From: himax Date: Fri, 23 May 2025 17:30:29 +0300 Subject: [PATCH 4/4] change trigger condition Signed-off-by: himax --- .github/workflows/step-output.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/step-output.yaml b/.github/workflows/step-output.yaml index e390209..95b2ea5 100644 --- a/.github/workflows/step-output.yaml +++ b/.github/workflows/step-output.yaml @@ -10,7 +10,10 @@ on: # - synchronize pull_request: types: [opened, reopened, synchronize, labeled, unlabeled] - + push: + branches: + - main + - release-* concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.ref }}