AAE-12046 - add pre-condition on approval (#8145)

* add pre-condition on approval

* adjustment

* add approval check

* devel check false

* devel check true

* restyling

* check with PR approved
This commit is contained in:
Maurizio Cacace 2023-01-16 12:41:58 +01:00 committed by GitHub
parent 616ae95c23
commit b99a574f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 3 deletions

View File

@ -73,8 +73,7 @@ jobs:
- name: Trigger Alpha ADF child build
shell: bash
if: ${{ contains(github.event.head_commit.message, '[trigger adf]') || inputs.cluster_operation == 'TRIGGER_ALPHA_ADF' || github.event.schedule == '0 12 * * *' }}
run: |
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
run: |
npm install github-api
./scripts/travis/update/update-project.sh -p $TRAVIS_BUILD_NUMBER -t $GH_TOKEN -v alpha -c $TRAVIS_COMMIT

View File

@ -64,13 +64,48 @@ env:
DOCKER_REPOSITORY_STORYBOOK: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/storybook"
DOCKER_REPOSITORY: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/demo-shell"
jobs:
jobs:
check-if-pr-is-approved:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if PR is approved
id: action
uses: kamatama41/get-pr-number-action@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Show the number
env:
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
shell: bash
if: ${{ github.event_name != 'schedule' }}
run: |
if [[ "$DEVEL_FLAG" = false ]] ; then
echo "PR number is: ${{ 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')
if [[ $checkApproval ]]; then
echo "PR approved"
else
echo "PR not approved yet"
exit 1
fi
else
echo "you are on your branch: skipping the check. REMEMBER to put DEVEL_FLAG to FALSE before the final merge!"
fi
setup:
# long timeout required when cache has to be recreated
timeout-minutes: 30
name: "Setup"
runs-on: ubuntu-22.04
needs: [check-if-pr-is-approved]
steps:
- name: Checkout repository
uses: actions/checkout@v3