From 2bdaa86e94778468a7901391f702098eb3bdb802 Mon Sep 17 00:00:00 2001 From: Trinh Pham <9128061+trinhpham@users.noreply.github.com> Date: Sat, 12 Oct 2024 05:52:01 +0000 Subject: [PATCH] Use action --- .github/workflows/weekly-scanner.yaml | 29 +++++++++++++++------------ repositories.json | 7 +++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/weekly-scanner.yaml b/.github/workflows/weekly-scanner.yaml index 152f12c..2961810 100644 --- a/.github/workflows/weekly-scanner.yaml +++ b/.github/workflows/weekly-scanner.yaml @@ -9,22 +9,22 @@ jobs: matrix-setup: runs-on: ubuntu-latest outputs: - matrix: ${{ steps.matrix.outputs.value }} + matrix: ${{ steps.matrix.outputs.matrix }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - id: matrix - run: | - echo "value=$(jq -c < repositories.json | jq -R | sed -e 's/^"//' -e 's/"$//')" >> $GITHUB_OUTPUT - - run: | - echo "${{ steps.matrix.outputs.value }}" + - name: Checkout + uses: actions/checkout@v3 + + - name: Get Matrix + id: matrix + uses: Surnet/get-json-matrix@v1 + with: + filepath: ./repositories.json check-and-publish-helm-charts: - needs: ["matrix-setup"] + needs: matrix-setup runs-on: ubuntu-latest strategy: - matrix: - value: ${{fromJSON(needs.matrix-setup.outputs.matrix)}} + matrix: ${{ fromJson(needs.matrix-setup.outputs.matrix) }} steps: - name: Set up Helm uses: azure/setup-helm@v4 @@ -37,15 +37,18 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Read repositories list and loop + env: + REPO_INFO: ${{ toJSON(matrix.value) }} # path to repositories, chart_paths, and tag_regex run: | - REPO_INFO=${{ matrix.value }} # path to repositories, chart_paths, and tag_regex + set -x + set +e OCI_REGISTRY='oci://registry-1.docker.io/ez4devcharts' # modify this if your registry differs # Ensure jq is installed sudo apt-get update && sudo apt-get install -y jq # Parse repo info - REPO_NAME=$(echo $REPO_INFO | jq -r '.repository') + REPO_NAME=${{ matrix.key }} CHART_PATH=$(echo $REPO_INFO | jq -r '.chart_path') CHART_NAME=$(echo $REPO_INFO | jq -r '.chart_name') TAG_REGEX=$(echo $REPO_INFO | jq -r '.tag_regex') diff --git a/repositories.json b/repositories.json index 08d96db..93a71d8 100644 --- a/repositories.json +++ b/repositories.json @@ -1,8 +1,7 @@ -[ - { - "repository": "syseleven/designate-certmanager-webhook", +{ + "syseleven/designate-certmanager-webhook": { "chart_path": "helm/designate-certmanager-webhook", "chart_name": "designate-certmanager-webhook", "tag_regex": "helm-\\K[0-9]+\\.[0-9]+\\.[0-9]+" } -] \ No newline at end of file +} \ No newline at end of file