[AAE-12412] bot & schedule check fix

This commit is contained in:
Marco Carrozzo
2023-02-03 16:35:29 +01:00
committed by GitHub
parent 857f9bd2b4
commit a0333b1d9c

View File

@@ -8,6 +8,11 @@ on:
required: false required: false
type: boolean type: boolean
default: true default: true
devel:
description: 'devel'
required: false
type: string
default: false
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
branches: branches:
@@ -64,41 +69,50 @@ env:
DOCKER_REPOSITORY_STORYBOOK: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/storybook" DOCKER_REPOSITORY_STORYBOOK: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/storybook"
DOCKER_REPOSITORY: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/demo-shell" DOCKER_REPOSITORY: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/demo-shell"
jobs: jobs:
check-if-pr-is-approved: check-if-pr-is-approved:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if PR is approved - name: Check if PR is approved
id: action id: action
if: ${{ github.event_name != 'schedule' || github.actor != 'dependabot[bot]' || github.actor != 'alfresco-build' }} if: ${{ github.event_name != 'schedule' }}
uses: kamatama41/get-pr-number-action@v0 uses: kamatama41/get-pr-number-action@5c77b38a1b4974ebf8a9521a689f38a5898eadd6
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
- name: check if pr is approved
- name: Show the number
env: env:
DEVEL_FLAG: ${{ inputs.devel }}
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
DEVEL_FLAG: false #put it to true if you need to develop the pipeline on your own branch. before the final merge put it to false skip_check: "false"
shell: bash
if: ${{ github.event_name != 'schedule' || github.actor != 'dependabot[bot]' || github.actor != 'alfresco-build' }}
run: | run: |
if [[ "$DEVEL_FLAG" = false ]] ; then if [ "${{ github.actor }}" == "dependabot[bot]" ] || [ "${{ github.actor }}" == "alfresco-build" ]; then
echo "PR number is: ${{ steps.action.outputs.number }}" echo -e "\033[32mCommit by ${{ github.actor }}. No need for approval.\033[0m"
skip_check="true"
fi
if [ "${{ github.event_name }}" == "schedule" ]; then
echo -e "\033[32mSchedule event\033[0m"
skip_check="true"
fi
if [[ "$DEVEL_FLAG" == "true" ]]; then
echo -e "\033[32mDevel flag\033[0m"
skip_check="true"
fi
if [ "$skip_check" == "false" ]; then
echo "Checking PR approval"
prNumber=${{ steps.action.outputs.number }} prNumber=${{ steps.action.outputs.number }}
checkApproval=$(gh api /repos/Alfresco/alfresco-ng2-components/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login') checkApproval=$(gh api /repos/Alfresco/alfresco-ng2-components/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login')
if [[ $checkApproval ]]; then if [[ $checkApproval ]]; then
echo "PR approved" echo -e "\033[32mPR approved\033[0m"
else else
echo "PR not approved yet" echo -e "\033[31mPR NOT approved\033[0m"
exit 1 exit 1
fi fi
else
echo "you are on your branch: skipping the check. REMEMBER to put DEVEL_FLAG to FALSE before the final merge!"
fi fi
setup: setup:
@@ -349,4 +363,3 @@ jobs:
check-ps-cloud-env: ${{ matrix.e2e-test.check-ps-cloud-env }} check-ps-cloud-env: ${{ matrix.e2e-test.check-ps-cloud-env }}
check-external-cs-env: ${{ matrix.e2e-test.check-external-cs-env }} check-external-cs-env: ${{ matrix.e2e-test.check-external-cs-env }}
apa-proxy: ${{ matrix.e2e-test.apa-proxy }} apa-proxy: ${{ matrix.e2e-test.apa-proxy }}
#