From e5238adde0591be4a9882a54b5e1c3d0d0488ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Sat, 5 Feb 2022 12:45:27 +0100 Subject: [PATCH] ci: Prevent duplicate CI runs on release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .github/workflows/charts-release.yaml | 21 +++++++++++++++---- .../workflows/meta-label-pr-ci-status.yaml | 8 ------- .github/workflows/pr-metadata.yaml | 1 + 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 355f3764..a25b57b8 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -25,7 +25,6 @@ jobs: uses: actions/checkout@v2 with: token: ${{ steps.generate-token.outputs.token }} - ref: master fetch-depth: 0 - name: Install Kubernetes tools @@ -64,19 +63,33 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 with: file_pattern: charts/**/ - commit_message: "chore: Auto-update chart README" + commit_message: "chore: Auto-update chart README [skip ci]" commit_user_name: k8s-at-home[bot] commit_user_email: k8s-at-home[bot]@users.noreply.github.com commit_author: k8s-at-home[bot] + - name: Save commit hash + id: save-commit-hash + run: | + if [ "${{ steps.create-commit.outputs.changes_detected || 'unknown' }}" == "true" ]; then + echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}' + else + echo "::set-output name=commit_hash::${GITHUB_SHA}" + fi + + - name: Checkout + uses: actions/checkout@v2 + with: + token: ${{ steps.generate-token.outputs.token }} + ref: ${{ steps.save-commit-hash.outputs.commit_hash }} + fetch-depth: 0 + - name: Configure Git - if: steps.create-commit.outputs.changes_detected == 'false' run: | git config user.name "k8s-at-home[bot]" git config user.email "k8s-at-home[bot]@users.noreply.github.com" - name: Run chart-releaser - if: steps.create-commit.outputs.changes_detected == 'false' uses: helm/chart-releaser-action@v1.2.1 with: charts_dir: charts/* diff --git a/.github/workflows/meta-label-pr-ci-status.yaml b/.github/workflows/meta-label-pr-ci-status.yaml index f520a707..222db037 100644 --- a/.github/workflows/meta-label-pr-ci-status.yaml +++ b/.github/workflows/meta-label-pr-ci-status.yaml @@ -40,14 +40,6 @@ jobs: with: path: ./pr_metadata/pr_number.txt - - name: Remove workflow artifact - uses: riskledger/delete-artifacts@v1 - with: - github_token: ${{ steps.generate-token.outputs.token }} - workflow: pr-validate.yaml - run_id: ${{ github.event.workflow_run.id }} - name: pr_metadata - - name: "Get workflow job status" uses: actions/github-script@v5 id: get-workflow-jobs diff --git a/.github/workflows/pr-metadata.yaml b/.github/workflows/pr-metadata.yaml index 97fc780e..87e3df91 100644 --- a/.github/workflows/pr-metadata.yaml +++ b/.github/workflows/pr-metadata.yaml @@ -42,6 +42,7 @@ jobs: with: name: pr_metadata path: ./pr_number.txt + retention-days: 5 pr-changes: name: Collect PR changes