[CI] Move check_labels to github actions (#8099)

* move lib.sh to common dir

* make check-labels a github action workflow
This commit is contained in:
Martin Pugh
2021-02-11 13:34:43 +01:00
committed by GitHub
parent 6a964c5df0
commit 07e4b9c997
7 changed files with 39 additions and 25 deletions
+16
View File
@@ -0,0 +1,16 @@
name: Check labels
on:
pull_request:
types: [labeled, opened, synchronize, unlabeled]
jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check labels
run: bash ${{ github.workspace }}/.maintain/github/check_labels.sh
env:
GITHUB_PR: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-11
View File
@@ -687,14 +687,3 @@ validator 4 4:
<<: *validator-deploy <<: *validator-deploy
script: script:
- ./.maintain/flamingfir-deploy.sh flamingfir-validator4 - ./.maintain/flamingfir-deploy.sh flamingfir-validator4
#### stage: .post
check-labels:
stage: .post
image: paritytech/tools:latest
<<: *kubernetes-build
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
script:
- ./.maintain/gitlab/check_labels.sh
@@ -66,11 +66,17 @@ has_label(){
repo="$1" repo="$1"
pr_id="$2" pr_id="$2"
label="$3" label="$3"
# These will exist if the function is called in Gitlab.
# If the function's called in Github, we should have GITHUB_ACCESS_TOKEN set
# already.
if [ -n "$GITHUB_RELEASE_TOKEN" ]; then if [ -n "$GITHUB_RELEASE_TOKEN" ]; then
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id") GITHUB_TOKEN="$GITHUB_RELEASE_TOKEN"
else elif [ -n "$GITHUB_PR_TOKEN" ]; then
out=$(curl -H "Authorization: token $GITHUB_PR_TOKEN" -s "$api_base/$repo/pulls/$pr_id") GITHUB_TOKEN="$GITHUB_PR_TOKEN"
fi fi
out=$(curl -H "Authorization: token $GITHUB_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ] [ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
} }
@@ -1,11 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#shellcheck source=lib.sh #shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"
repo="$GITHUB_REPOSITORY"
pr="$GITHUB_PR"
ensure_labels() { ensure_labels() {
for label in "$@"; do for label in "$@"; do
if has_label 'paritytech/substrate' "$CI_COMMIT_BRANCH" "$label"; then if has_label "$repo" "$pr" "$label"; then
return 0 return 0
fi fi
done done
@@ -27,7 +30,7 @@ criticality_labels=(
'C9-critical' 'C9-critical'
) )
echo "[+] Checking release notes (B) labels for $CI_COMMIT_BRANCH" echo "[+] Checking release notes (B) labels"
if ensure_labels "${releasenotes_labels[@]}"; then if ensure_labels "${releasenotes_labels[@]}"; then
echo "[+] Release notes label detected. All is well." echo "[+] Release notes label detected. All is well."
else else
@@ -35,7 +38,7 @@ else
exit 1 exit 1
fi fi
echo "[+] Checking release criticality (C) labels for $CI_COMMIT_BRANCH" echo "[+] Checking release criticality (C) labels"
if ensure_labels "${criticality_labels[@]}"; then if ensure_labels "${criticality_labels[@]}"; then
echo "[+] Release criticality label detected. All is well." echo "[+] Release criticality label detected. All is well."
else else
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck source=lib.sh # shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"
version="$CI_COMMIT_TAG" version="$CI_COMMIT_TAG"
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck source=lib.sh # shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"
version="$2" version="$2"
last_version="$1" last_version="$1"
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck source=lib.sh # shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"
version="$CI_COMMIT_TAG" version="$CI_COMMIT_TAG"