From 3706a36aa50be172667af33e932853d77f313dec Mon Sep 17 00:00:00 2001 From: chrisdca Date: Thu, 18 Sep 2025 23:01:21 -0500 Subject: [PATCH 1/4] feat: add reusable and composite workflow --- .../utilities/composite-workflow.yml | 19 +++++++++++++ .../workflows/utilities/reusable-workflow.yml | 28 +++++++++++++++++++ .github/workflows/workflow-ci.yml | 17 +++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/utilities/composite-workflow.yml create mode 100644 .github/workflows/utilities/reusable-workflow.yml create mode 100644 .github/workflows/workflow-ci.yml diff --git a/.github/workflows/utilities/composite-workflow.yml b/.github/workflows/utilities/composite-workflow.yml new file mode 100644 index 0000000..ee30135 --- /dev/null +++ b/.github/workflows/utilities/composite-workflow.yml @@ -0,0 +1,19 @@ +name: Greeting Workflow +description: A reusable workflow that greets a user by name. + +inputs: + name: + description: "Nombre de la persona a saludar" + required: true + default: "Usuario" + message: + description: "Mensaje personalizado" + required: false + default: "Hello" + +runs: + using: "composite" + steps: + - name: Greet User + run: echo "${{ inputs.message }}, ${{ inputs.name }}!" + shell: bash diff --git a/.github/workflows/utilities/reusable-workflow.yml b/.github/workflows/utilities/reusable-workflow.yml new file mode 100644 index 0000000..e9349a7 --- /dev/null +++ b/.github/workflows/utilities/reusable-workflow.yml @@ -0,0 +1,28 @@ +name: CI Workflow +description: A reusable workflow for continuous integration tasks. +on: workflow_call +jobs: + CI: + name: Setup Node.js Environment + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "22.x" + cache: "pnpm" + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm install + + - name: Run tests + run: pnpm test + + - name: Build project + run: pnpm run build diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml new file mode 100644 index 0000000..50990bd --- /dev/null +++ b/.github/workflows/workflow-ci.yml @@ -0,0 +1,17 @@ +name: Workflow CI +description: A workflow that calls reusable and composite workflows. +on: [push] +jobs: + call-reusable-workflow: + runs-on: ubuntu-latest + steps: + - name: Call CI Workflow + uses: ./.github/workflows/utilities/reusable-workflow.yml + call-composite-workflow: + runs-on: ubuntu-latest + steps: + - name: Call Greeting Workflow + uses: ./.github/workflows/utilities/composite-workflow.yml + with: + name: "Desarrollador" + message: "Hola" From 5867cfdfbbcdb63ff3fc60ae6b16d5856eeee948 Mon Sep 17 00:00:00 2001 From: chrisdca Date: Thu, 18 Sep 2025 23:06:07 -0500 Subject: [PATCH 2/4] fix: add missing checkout step in reusable and composite workflows --- .github/workflows/workflow-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 50990bd..7ca0cce 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -5,11 +5,17 @@ jobs: call-reusable-workflow: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Call CI Workflow uses: ./.github/workflows/utilities/reusable-workflow.yml call-composite-workflow: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Call Greeting Workflow uses: ./.github/workflows/utilities/composite-workflow.yml with: From 53e1db872527412ec2b741a37b38b62bd9bfb460 Mon Sep 17 00:00:00 2001 From: chrisdca Date: Thu, 18 Sep 2025 23:12:09 -0500 Subject: [PATCH 3/4] fix: remove redundant checkout steps in CI workflows --- .github/workflows/workflow-ci.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 7ca0cce..108693b 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -5,17 +5,11 @@ jobs: call-reusable-workflow: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Call CI Workflow - uses: ./.github/workflows/utilities/reusable-workflow.yml + uses: ./.github/workflows/utilities/reusable-workflow.yml@main call-composite-workflow: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Call Greeting Workflow uses: ./.github/workflows/utilities/composite-workflow.yml with: From 5ac125ce128562c65bc4ab6a9ddcb310b6cde6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=ADaz?= <164126437+christianncode@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:20:20 -0500 Subject: [PATCH 4/4] Potential fix for code scanning alert no. 14: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/workflow-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 108693b..144a2b4 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -1,5 +1,7 @@ name: Workflow CI description: A workflow that calls reusable and composite workflows. +permissions: + contents: read on: [push] jobs: call-reusable-workflow: