mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-14 11:54:28 +01:00
Let's make sure we cancel previous runs, mainly as we have some of those that take a lot of time to run, whenever the PR is updated. This is based on the following stack overflow suggestion: https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre This is very much needed as we don't want to wait for a long time to have access to a runner because of other runners are still being used performing a task that's meaningless due to the PR update. Fixes: #7298 Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
59 lines
1.9 KiB
YAML
59 lines
1.9 KiB
YAML
# Copyright (c) 2020 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
name: Ensure PR has required porting labels
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- labeled
|
|
- unlabeled
|
|
branches:
|
|
- main
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check-pr-porting-labels:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install hub
|
|
if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }}
|
|
run: |
|
|
HUB_ARCH="amd64"
|
|
HUB_VER=$(curl -sL "https://api.github.com/repos/github/hub/releases/latest" |\
|
|
jq -r .tag_name | sed 's/^v//')
|
|
curl -sL \
|
|
"https://github.com/github/hub/releases/download/v${HUB_VER}/hub-linux-${HUB_ARCH}-${HUB_VER}.tgz" |\
|
|
tar xz --strip-components=2 --wildcards '*/bin/hub' && \
|
|
sudo install hub /usr/local/bin
|
|
|
|
- name: Checkout code to allow hub to communicate with the project
|
|
if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }}
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install porting checker script
|
|
run: |
|
|
# Clone into a temporary directory to avoid overwriting
|
|
# any existing github directory.
|
|
pushd $(mktemp -d) &>/dev/null
|
|
git clone --single-branch --depth 1 "https://github.com/kata-containers/.github" && cd .github/scripts
|
|
sudo install pr-porting-checks.sh /usr/local/bin
|
|
popd &>/dev/null
|
|
|
|
- name: Stop PR being merged unless it has a correct set of porting labels
|
|
if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.KATA_GITHUB_ACTIONS_TOKEN }}
|
|
run: |
|
|
pr=${{ github.event.number }}
|
|
repo=${{ github.repository }}
|
|
|
|
pr-porting-checks.sh "$pr" "$repo"
|