7575 exit 1
7676 fi
7777
78+ check-if-pr-is-approved :
79+ runs-on : ubuntu-latest
80+ steps :
81+ - name : Checkout repository
82+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+ with :
84+ fetch-depth : 0
85+
86+ - name : Get branch name
87+ uses : Alfresco/alfresco-build-tools/.github/actions/get-branch-name@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
88+
89+ - name : Save commit message
90+ uses : Alfresco/alfresco-build-tools/.github/actions/get-commit-message@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
91+
92+ - name : ci:force flag parser
93+ shell : bash
94+ run : |
95+ if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.actor }}" == "dependabot[bot]" ]; then
96+ echo -e "\033[32mci:force check can be skipped\033[0m"
97+ skip_check="true"
98+ elif [[ "$COMMIT_MESSAGE" == *"[ci:force]"* ]]; then
99+ echo -e "\033[32m[ci:force] flag detected. No need for approval.\033[0m"
100+ skip_check="true"
101+ fi
102+
103+ - name : Get PR number
104+ if : ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
105+ uses : kamatama41/get-pr-number-action@0bcaab5752c0b699149e74667c8ce2f764cbb7fa # v0.9.1
106+ id : action
107+ with :
108+ github_token : ${{ secrets.GITHUB_TOKEN }}
109+
110+ - name : show pr number
111+ shell : bash
112+ run : |
113+ echo "PR: ${{ steps.action.outputs.number }}"
114+
115+ - name : check if pr is approved
116+ env :
117+ DEVEL_FLAG : ${{ inputs.devel }}
118+ GH_TOKEN : ${{ github.token }}
119+ skip_check : " false"
120+ run : |
121+ if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.actor }}" == "dependabot[bot]" ]; then
122+ echo -e "\033[32mci:force check can be skipped\033[0m"
123+ skip_check="true"
124+ elif [[ "$COMMIT_MESSAGE" == *"[ci:force]"* ]]; then
125+ echo -e "\033[32m[ci:force] flag detected. No need for approval.\033[0m"
126+ skip_check="true"
127+ fi
128+
129+ if [ "${{ github.actor }}" == "dependabot[bot]" ] || [ "${{ github.actor }}" == "alfresco-build" ]; then
130+ echo -e "\033[32mCommit by ${{ github.actor }}. No need for approval.\033[0m"
131+ skip_check="true"
132+ fi
133+ if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
134+ echo -e "\033[32mSchedule event\033[0m"
135+ skip_check="true"
136+ fi
137+
138+ if [[ "$DEVEL_FLAG" == "true" ]]; then
139+ echo -e "\033[32mDevel flag\033[0m"
140+ skip_check="true"
141+ fi
142+
143+ if [ "$skip_check" == "false" ]; then
144+ echo "Checking PR approval"
145+ prNumber=${{ steps.action.outputs.number }}
146+ echo "PR: $prNumber"
147+ checkApproval=$(gh api /repos/$GITHUB_REPOSITORY/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login')
148+ if [[ $checkApproval ]]; then
149+ echo -e "\033[32mPR approved\033[0m"
150+ else
151+ echo -e "\033[31mPR NOT approved\033[0m"
152+ exit 1
153+ fi
154+ fi
155+
78156 generate-affected-matrix :
79157 name : " Generate affected matrix"
80158 runs-on : ubuntu-latest
@@ -100,13 +178,42 @@ jobs:
100178 echo "Matrix JSON: $MATRIX_JSON"
101179 echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
102180
181+ lint :
182+ # long timeout required when cache has to be recreated
183+ timeout-minutes : 30
184+ name : " Lint"
185+ runs-on : ubuntu-latest
186+ needs : []
187+ steps :
188+ - name : Checkout repository
189+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
190+ with :
191+ fetch-depth : 0 # Fetch all history for all tags and branches
192+ - uses : ./.github/actions/setup
193+ - run : npx nx affected --target=lint
194+
103195 trigger-build :
104196 name : " Build Libs"
105197 needs : [generate-affected-matrix]
106198 uses : ./.github/workflows/unit-test-workflow.yml
107199 with :
108200 matrix : ${{ needs.generate-affected-matrix.outputs.matrix }}
109201
202+ build-storybook :
203+ name : " Build Storybook"
204+ needs : [generate-affected-matrix]
205+ runs-on : ubuntu-latest
206+ steps :
207+ - name : Checkout repository
208+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
209+ with :
210+ fetch-depth : 0
211+ - name : Setup environment
212+ uses : ./.github/actions/setup
213+ - name : Build Storybook
214+ run : |
215+ NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected --target=build-storybook $NX_CALCULATION_FLAGS --configuration=ci
216+
110217 trigger-unit-tests :
111218 name : " Unit Tests"
112219 needs : [generate-affected-matrix]
0 commit comments