Revert "AAE-29010 GH actions rerun after approval (#10772) (#10774)" (#10809)

This reverts commit f6c446498a79aa25981525e3f87ef50f78e120c7.
This commit is contained in:
Vito Albano 2025-04-22 10:33:09 +01:00 committed by GitHub
parent fdd4f6c081
commit d0b2915c88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 51 deletions

View File

@ -18,15 +18,11 @@ runs:
- name: base vars - name: base vars
shell: bash shell: bash
run: | run: |
if [[ "${{ github.event_name }}" == "pull_request_review" ]]; then
echo "BASE_HASH=$(git merge-base origin/${{ env.BASE_PR_REF }} HEAD) >> $GITHUB_ENV";
else
echo "BASE_HASH=$(git merge-base origin/${{ env.BASE_REF }} HEAD) >> $GITHUB_ENV";
fi
{ {
echo "GIT_HASH=$(git rev-parse HEAD)"; echo "GIT_HASH=$(git rev-parse HEAD)";
echo "BASE_HASH=$(git merge-base origin/${GITHUB_BASE_REF} HEAD)";
echo "HEAD_HASH=HEAD"; echo "HEAD_HASH=HEAD";
echo "HEAD_COMMIT_HASH=${{ env.GH_COMMIT }}"; echo "HEAD_COMMIT_HASH=${GH_COMMIT}";
echo "NX_CALCULATION_FLAGS=--all"; echo "NX_CALCULATION_FLAGS=--all";
echo "BUILD_OPTS=--configuration production"; echo "BUILD_OPTS=--configuration production";
echo CI_FORCE_RUN=false; echo CI_FORCE_RUN=false;
@ -41,21 +37,15 @@ runs:
echo "BREAK_ACTION=true" >> $GITHUB_ENV echo "BREAK_ACTION=true" >> $GITHUB_ENV
- name: PULL_REQUEST event - name: PULL_REQUEST event
if: ${{ env.BREAK_ACTION == false && (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && !github.event.pull_request.merged }} if: ${{ env.BREAK_ACTION == false && github.event_name == 'pull_request' && !github.event.pull_request.merged }}
shell: bash shell: bash
run: | run: |
echo "Setting up CI flags for Pull Request event" echo "Setting up CI flags for Pull Request event"
if [[ "${{ github.event_name }}" == "pull_request_review" ]]; then NX_CALCULATION_FLAGS="--base=origin/${GITHUB_BASE_REF} --head=$HEAD_HASH"
NX_CALCULATION_FLAGS="--base=origin/${{ env.BASE_PR_REF }} --head=$HEAD_HASH"
BASE_HASH="origin/${{ env.BASE_PR_REF }}"
else
NX_CALCULATION_FLAGS="--base=origin/${{ env.BASE_REF }} --head=$HEAD_HASH"
BASE_HASH="origin/${{ env.BASE_REF }}"
fi
{ {
echo "NX_CALCULATION_FLAGS=$NX_CALCULATION_FLAGS"; echo "NX_CALCULATION_FLAGS=$NX_CALCULATION_FLAGS";
echo "BASE_HASH=$BASE_HASH"; echo "BASE_HASH=origin/${GITHUB_BASE_REF}";
echo "BREAK_ACTION=true"; echo "BREAK_ACTION=true";
} >> $GITHUB_ENV } >> $GITHUB_ENV
- name: RELEASE on master/develop patch branch - name: RELEASE on master/develop patch branch
@ -69,10 +59,10 @@ runs:
# into develop-patch* # into develop-patch*
echo "Setting up CI flags for Push develop patch" echo "Setting up CI flags for Push develop patch"
else else
echo "Setting up CI flags for Push on develop branch" echo "Setting up CI flags for Push on develop branch"
# base=$(git describe --tags $(git rev-list --tags --max-count=1)) # base=$(git describe --tags $(git rev-list --tags --max-count=1))
# we publish always all the libs until we don't handle partial release # we publish always all the libs until we don't handle partial release
echo "NX_CALCULATION_FLAGS=--all" >> $GITHUB_ENV echo "NX_CALCULATION_FLAGS=--all" >> $GITHUB_ENV
fi fi
echo "BREAK_ACTION=true" >> $GITHUB_ENV echo "BREAK_ACTION=true" >> $GITHUB_ENV

View File

@ -25,8 +25,6 @@ on:
- master - master
- develop-patch* - develop-patch*
- master-patch* - master-patch*
pull_request_review:
types: [submitted, dismissed]
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
@ -34,9 +32,7 @@ concurrency:
env: env:
BASE_REF: ${{ github.base_ref }} BASE_REF: ${{ github.base_ref }}
BASE_PR_REF: ${{ github.event.pull_request.base.ref }}
HEAD_REF: ${{ github.head_ref }} HEAD_REF: ${{ github.head_ref }}
HEAD_PR_REF: ${{ github.event.pull_request.head.ref }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_BRANCH: ${{ github.ref_name }} GITHUB_BRANCH: ${{ github.ref_name }}
@ -45,7 +41,6 @@ env:
BUILD_ID: ${{ github.run_id }} BUILD_ID: ${{ github.run_id }}
GH_RUN_NUMBER: ${{ github.run_attempt }} GH_RUN_NUMBER: ${{ github.run_attempt }}
GH_BUILD_NUMBER: ${{ github.run_id }} GH_BUILD_NUMBER: ${{ github.run_id }}
GH_PR_NUMBER: ${{github.event.pull_request.number}}
JOB_ID: ${{ github.run_id }} JOB_ID: ${{ github.run_id }}
LOG_LEVEL: "ERROR" LOG_LEVEL: "ERROR"
S3_BUILD_BUCKET_SHORT_NAME: ${{ secrets.S3_BUILD_BUCKET_SHORT_NAME }} S3_BUILD_BUCKET_SHORT_NAME: ${{ secrets.S3_BUILD_BUCKET_SHORT_NAME }}
@ -82,9 +77,6 @@ jobs:
check-if-pr-is-approved: check-if-pr-is-approved:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
isLabeledWithDoNotMerge: ${{ steps.check-label.outputs.isLabeledWithDoNotMerge }}
pr_approved: ${{ steps.check-approval.outputs.pr_approved }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@ -108,22 +100,19 @@ jobs:
skip_check="true" skip_check="true"
fi fi
- name: Check if PR is labeled - name: Get PR number
id: check-label if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
run: | uses: kamatama41/get-pr-number-action@0bcaab5752c0b699149e74667c8ce2f764cbb7fa # v0.9.1
if echo '${{ toJson(github.event.pull_request.labels) }}' | jq -e '.[] | select(.name | contains("do not merge"))'; then id: action
echo "::warning::PR is labeled as 'do not merge'" with:
echo "isLabeledWithDoNotMerge=true" >> $GITHUB_ENV github_token: ${{ secrets.GITHUB_TOKEN }}
echo "isLabeledWithDoNotMerge=true" >> $GITHUB_OUTPUT
else
echo "PR is not labeled as 'do not merge'"
echo "isLabeledWithDoNotMerge=false" >> $GITHUB_ENV
echo "isLabeledWithDoNotMerge=false" >> $GITHUB_OUTPUT
fi
- name: Check if PR is approved - name: show pr number
id: check-approval shell: bash
if: env.isLabeledWithDoNotMerge == 'false' run: |
echo "PR: ${{ steps.action.outputs.number }}"
- name: check if pr is approved
env: env:
DEVEL_FLAG: ${{ inputs.devel }} DEVEL_FLAG: ${{ inputs.devel }}
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
@ -150,17 +139,17 @@ jobs:
echo -e "\033[32mDevel flag\033[0m" echo -e "\033[32mDevel flag\033[0m"
skip_check="true" skip_check="true"
fi fi
if [ "$skip_check" == "false" ]; then if [ "$skip_check" == "false" ]; then
echo "Checking PR approval" echo "Checking PR approval"
echo "PR: $GH_PR_NUMBER" prNumber=${{ steps.action.outputs.number }}
echo "PR: $prNumber"
if gh pr view $GH_PR_NUMBER --json reviews | jq -e '.reviews[] | select(.state == "APPROVED")'; then checkApproval=$(gh api /repos/$GITHUB_REPOSITORY/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login')
if [[ $checkApproval ]]; then
echo -e "\033[32mPR approved\033[0m" echo -e "\033[32mPR approved\033[0m"
echo "pr_approved=true" >> $GITHUB_OUTPUT
else else
echo "::error::PR NOT approved"
echo -e "\033[31mPR NOT approved\033[0m" echo -e "\033[31mPR NOT approved\033[0m"
echo "pr_approved=false" >> $GITHUB_OUTPUT exit 1
fi fi
fi fi
@ -170,7 +159,6 @@ jobs:
name: "Setup" name: "Setup"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [check-if-pr-is-approved, pre-checks] needs: [check-if-pr-is-approved, pre-checks]
if: ${{ needs.check-if-pr-is-approved.outputs.isLabeledWithDoNotMerge == 'false' && needs.check-if-pr-is-approved.outputs.pr_approved == 'true' }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2