From d5c6cbc33730b1468945e2caacb5917653f02fcb Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:39:03 +0200 Subject: [PATCH 1/8] Replace curl with gh --- .github/workflows/helm-chart-release.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 2ebe8225..89c3ef75 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -9,12 +9,21 @@ jobs: contents: write runs-on: ubuntu-latest steps: + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + + - name: Authenticate GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo $GITHUB_TOKEN | gh auth login --with-token + - name: Wait for container images build run: | while :; do - result=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/actions/runs | \ - jq -r '.workflow_runs | map(select(.name == "Release container images")) | sort_by(.created_at) | reverse | .[0]') + result=$(gh api repos/:owner/:repo/actions/workflows | jq -r '.workflows[] | select(.name=="Release container images") | .id' | xargs -I {} gh api repos/:owner/:repo/actions/workflows/{}/runs --jq '.workflow_runs | max_by(.run_number)') status=$(echo "$result" | jq -r '.status') conclusion=$(echo "$result" | jq -r '.conclusion') if [[ "$status" == "completed" ]]; then From 0db1865e4b705d10344d62ab4e553b46e9e4df90 Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:46:44 +0200 Subject: [PATCH 2/8] Quick validation of the solution --- .github/workflows/helm-chart-release.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 89c3ef75..a9b50351 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -2,6 +2,9 @@ name: Release Helm Chart on: workflow_dispatch: + push: + branches: + - main jobs: release: @@ -46,27 +49,30 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout + if: false uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Helm - if: true + if: false uses: azure/setup-helm@v4 with: token: ${{ github.token }} - name: Add dependencies - if: true + if: false run: | helm repo add bitnami https://charts.bitnami.com/bitnami - name: Configure git + if: false run: | git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - name: Semantic Release + if: false id: semantic-release uses: cycjimmy/semantic-release-action@v4 env: @@ -78,6 +84,7 @@ jobs: semantic-release-helm3@2.9.3 - name: Run chart-releaser + if: false uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" From 6dc23504c0abab900d6b810add9f99657e2000ab Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:47:08 +0200 Subject: [PATCH 3/8] Quick validation of the solution --- .github/workflows/helm-chart-release.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index a9b50351..dacd91b4 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -5,6 +5,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: release: From 746752009be41f5c81325b45a53f577df2b23048 Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:51:34 +0200 Subject: [PATCH 4/8] Fix gh login --- .github/workflows/helm-chart-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index dacd91b4..338ae943 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -24,7 +24,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - echo $GITHUB_TOKEN | gh auth login --with-token + gh auth login --with-token - name: Wait for container images build run: | From 0234105780f15fec3718dd15a5d4727438446870 Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:52:19 +0200 Subject: [PATCH 5/8] Remove gh install step --- .github/workflows/helm-chart-release.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 338ae943..faabe3bd 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -15,11 +15,6 @@ jobs: contents: write runs-on: ubuntu-latest steps: - - name: Install GitHub CLI - run: | - sudo apt-get update - sudo apt-get install -y gh - - name: Authenticate GitHub CLI env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From bee0ec42758fd93e494c61ac46abf9d92d174fcb Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:54:57 +0200 Subject: [PATCH 6/8] Remove login step --- .github/workflows/helm-chart-release.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index faabe3bd..bfc00119 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -15,12 +15,6 @@ jobs: contents: write runs-on: ubuntu-latest steps: - - name: Authenticate GitHub CLI - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh auth login --with-token - - name: Wait for container images build run: | while :; do From 73d98aded953bbad2eb00a9a808acd007bf448b0 Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:56:26 +0200 Subject: [PATCH 7/8] Reorder steps --- .github/workflows/helm-chart-release.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index bfc00119..3eede643 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -15,6 +15,11 @@ jobs: contents: write runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Wait for container images build run: | while :; do @@ -40,12 +45,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - if: false - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Helm if: false uses: azure/setup-helm@v4 From fcbaaa62512ab78af34275ce04c800f56a884038 Mon Sep 17 00:00:00 2001 From: ppawlowski Date: Tue, 25 Jun 2024 09:57:38 +0200 Subject: [PATCH 8/8] Cleanup for the review --- .github/workflows/helm-chart-release.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 3eede643..71a62742 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -2,12 +2,6 @@ name: Release Helm Chart on: workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - main jobs: release: @@ -46,24 +40,20 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install Helm - if: false uses: azure/setup-helm@v4 with: token: ${{ github.token }} - name: Add dependencies - if: false run: | helm repo add bitnami https://charts.bitnami.com/bitnami - name: Configure git - if: false run: | git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - name: Semantic Release - if: false id: semantic-release uses: cycjimmy/semantic-release-action@v4 env: @@ -75,7 +65,6 @@ jobs: semantic-release-helm3@2.9.3 - name: Run chart-releaser - if: false uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"