From 13ca561ef89fc23cf0171dddba41cfba99ad07e7 Mon Sep 17 00:00:00 2001 From: mkabdelrahman Date: Wed, 4 Sep 2024 21:17:43 +0300 Subject: [PATCH] ci-pipline an action to setup environemtn --- .github/actions/setup-environment/action.yaml | 16 +++++++++ .github/workflows/pipeline.yaml | 33 ++++--------------- 2 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 .github/actions/setup-environment/action.yaml diff --git a/.github/actions/setup-environment/action.yaml b/.github/actions/setup-environment/action.yaml new file mode 100644 index 0000000..e71152f --- /dev/null +++ b/.github/actions/setup-environment/action.yaml @@ -0,0 +1,16 @@ +name: "Setup Environment" +description: "Sets up the environment by checking out code, setting up Go, and installing Task CLI." +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: stable + cache: false + + - name: Install Task CLI + uses: arduino/setup-task@v2 + with: + version: 3.x diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index d400c89..af168ae 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -7,15 +7,8 @@ jobs: name: Lint Application runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: stable - cache: false - - name: Install Task CLI - uses: arduino/setup-task@v2 - with: - version: 3.x + - name: Setup Environment + uses: ./.github/actions/setup-environment - name: Install GolangCI-Lint run: task instal-golangci-lint - name: Run Lint @@ -26,15 +19,8 @@ jobs: runs-on: ubuntu-latest needs: lint steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: stable - cache: false - - name: Install Task CLI - uses: arduino/setup-task@v2 - with: - version: 3.x + - name: Setup Environment + uses: ./.github/actions/setup-environment - name: Run Test run: task test @@ -43,15 +29,8 @@ jobs: runs-on: ubuntu-latest needs: test steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: stable - cache: false - - name: Install Task CLI - uses: arduino/setup-task@v2 - with: - version: 3.x + - name: Setup Environment + uses: ./.github/actions/setup-environment - name: Build run: task build - name: Copy Files