From f819a5b08f7cbc206c4b4e823491f3bca10b6a54 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 10 Dec 2024 16:33:26 +0100 Subject: [PATCH] github-actions: use concurrency: true if PRs --- .github/workflows/codeql-analysis.yml | 11 +++----- .github/workflows/docker.yml | 11 +++----- .github/workflows/go.yml | 36 +++------------------------ .github/workflows/releaser.yml | 11 +++----- .github/workflows/security.yml | 27 +++----------------- 5 files changed, 17 insertions(+), 79 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 370128b4..a0ec1ab7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,6 +9,10 @@ on: schedule: - cron: '0 11 * * 6' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: analyze: name: Analyze @@ -17,16 +21,9 @@ jobs: permissions: # required for all workflows security-events: write - # only required for workflows in private repositories - actions: write contents: read steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout repository uses: actions/checkout@v3 with: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 652f74b3..77ee84ac 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,20 +8,17 @@ on: required: true permissions: - # Required to stop running workflows - actions: write packages: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: build-docker-images: name: Build Docker Images runs-on: ubuntu-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a6db78f7..2fd13a0f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,9 +21,9 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -permissions: - # Required to stop running workflows - actions: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: # Check if there any dirty change for go mod tidy @@ -31,11 +31,6 @@ jobs: name: "Check go modules declaration" runs-on: ubuntu-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Install Go uses: actions/setup-go@v3 @@ -63,11 +58,6 @@ jobs: runs-on: ubuntu-latest needs: [golangci-lint, go-mod] steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 @@ -98,11 +88,6 @@ jobs: name: "GolangCI-lint" runs-on: ubuntu-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Install Go uses: actions/setup-go@v3 @@ -122,11 +107,6 @@ jobs: needs: [go-mod, compile-dryrun, golangci-lint] # run after golangci-lint action to not produce duplicated errors runs-on: ubuntu-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 @@ -160,11 +140,6 @@ jobs: needs: [go-mod, compile-dryrun, golangci-lint] # run after golangci-lint action to not produce duplicated errors runs-on: windows-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 @@ -198,11 +173,6 @@ jobs: needs: [go-mod, compile-dryrun, golangci-lint] # run after golangci-lint action to not produce duplicated errors runs-on: macos-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 4a1d7ac3..4c30d70e 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -7,9 +7,9 @@ on: description: 'Release version' required: true -permissions: - # Required to stop running workflows - actions: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: release: @@ -18,11 +18,6 @@ jobs: packages: read contents: write steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index b6c710d4..0dfee03d 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -9,9 +9,9 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -permissions: - # Required to stop running workflows - actions: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: vulns: @@ -19,11 +19,6 @@ jobs: continue-on-error: true runs-on: ubuntu-latest steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 - @@ -47,11 +42,6 @@ jobs: pull-requests: read steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 - @@ -79,15 +69,9 @@ jobs: # contents: read # security-events: write # pull-requests: read -# actions: write # # steps: # - -# name: Cancel previous workflows -# uses: styfle/cancel-workflow-action@0.9.1 -# with: -# access_token: ${{ secrets.GITHUB_TOKEN }} -# - # uses: actions/checkout@v3 # - # name: Run Snyk to check for vulnerabilities @@ -114,11 +98,6 @@ jobs: pull-requests: read steps: - - - name: Cancel previous workflows - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 -