From d848da21d310b2a847a73457059b5a2d93d9f154 Mon Sep 17 00:00:00 2001 From: Jeroen Op 't Eynde Date: Thu, 11 Jul 2024 11:13:35 +0200 Subject: [PATCH] feat: add argo-lint and install-argo-cli action (#171) - Split installation of argo-cli into separate `install-argo-cli` action - Update `trigger-argo-workflow` action using above - Introduce new `argo-lint` action --------- Co-authored-by: Iain Lane --- actions/argo-lint/action.yaml | 34 +++++++++++++++ actions/install-argo-cli/action.yaml | 50 +++++++++++++++++++++++ actions/trigger-argo-workflow/action.yaml | 46 +-------------------- 3 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 actions/argo-lint/action.yaml create mode 100644 actions/install-argo-cli/action.yaml diff --git a/actions/argo-lint/action.yaml b/actions/argo-lint/action.yaml new file mode 100644 index 000000000..6e3db1aa4 --- /dev/null +++ b/actions/argo-lint/action.yaml @@ -0,0 +1,34 @@ +name: Lint Argo Workflow files +description: Lint Argo workflow files + +inputs: + path: + description: | + Path to files for linting. + required: true + +runs: + using: composite + + steps: + - name: Checkout + env: + # In a composite action, these two need to be indirected via the + # environment, as per the GitHub actions documentation: + # https://docs.github.com/en/actions/learn-github-actions/contexts + action_repo: ${{ github.action_repository }} + action_ref: ${{ github.action_ref }} + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: ${{ env.action_repo }} + ref: ${{ env.action_ref }} + path: _shared-workflows-argo-lint + + - name: Install argo-cli + uses: ./_shared-workflows-argo-lint/actions/install-argo-cli + + - name: Run + env: + WORKFLOW_PATH: ${{ inputs.path }} + shell: bash + run: argo lint --offline "${WORKFLOW_PATH}" diff --git a/actions/install-argo-cli/action.yaml b/actions/install-argo-cli/action.yaml new file mode 100644 index 000000000..5eb286a40 --- /dev/null +++ b/actions/install-argo-cli/action.yaml @@ -0,0 +1,50 @@ +name: Install Argo cli +description: Install Argo cli + +inputs: + version: + description: | + Version of the Argo CLI to install. + default: 3.5.1 + +runs: + using: composite + + steps: + - name: Restore cache + id: restore + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + path: ${{ github.workspace }}/bin + key: argo-linux-amd64-${{ inputs.version }} + + - name: Fetch Github Release Asset + id: fetch_asset + if: steps.restore.outputs.cache-hit != 'true' + uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # 1.1.1 + with: + repo: "argoproj/argo-workflows" + version: "tags/v${{ inputs.version }}" + file: "argo-linux-amd64.gz" + target: ${{ github.workspace }}/bin/argo.gz + + - name: gunzip + id: gunzip + if: steps.fetch_asset.outcome == 'success' + shell: sh + run: | + gunzip ${{ github.workspace }}/bin/argo.gz + chmod +x ${{ github.workspace }}/bin/argo + + - name: Save to cache + id: save + if: steps.gunzip.outcome == 'success' + uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + path: ${{ github.workspace }}/bin + key: ${{ steps.restore.outputs.cache-primary-key }} + + - name: Add binary to path + shell: sh + run: | + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH diff --git a/actions/trigger-argo-workflow/action.yaml b/actions/trigger-argo-workflow/action.yaml index 126216470..498947256 100644 --- a/actions/trigger-argo-workflow/action.yaml +++ b/actions/trigger-argo-workflow/action.yaml @@ -40,13 +40,6 @@ runs: using: composite steps: - - name: Set argo version - id: argo-version - shell: sh - run: | - ARGO_VERSION=3.5.1 - echo "version=${ARGO_VERSION}" >> ${GITHUB_OUTPUT} - - name: Checkout env: # In a composite action, these two need to be indirected via the @@ -60,43 +53,8 @@ runs: ref: ${{ env.action_ref }} path: _shared-workflows-trigger-argo-workflow - - name: Restore cache - id: restore - uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 - with: - path: ${{ github.workspace }}/bin - key: argo-linux-amd64-${{ steps.argo-version.outputs.version }} - - - name: Fetch Github Release Asset - id: fetch_asset - if: steps.restore.outputs.cache-hit != 'true' - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # 1.1.1 - with: - repo: "argoproj/argo-workflows" - version: "tags/v${{ steps.argo-version.outputs.version }}" - file: "argo-linux-amd64.gz" - target: ${{ github.workspace }}/bin/argo.gz - - - name: gunzip - id: gunzip - if: steps.fetch_asset.outcome == 'success' - shell: sh - run: | - gunzip ${{ github.workspace }}/bin/argo.gz - chmod +x ${{ github.workspace }}/bin/argo - - - name: Save to cache - id: save - if: steps.gunzip.outcome == 'success' - uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 - with: - path: ${{ github.workspace }}/bin - key: ${{ steps.restore.outputs.cache-primary-key }} - - - name: Add binary to path - shell: sh - run: | - echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + - name: Install argo-cli + uses: ./_shared-workflows-trigger-argo-workflow/actions/install-argo-cli - name: Setup go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0