|
75 | 75 | ELMENTARY_INTERNAL_DBT_PKG_DIR: ${{ github.workspace }}/elementary/elementary/monitor/dbt_project |
76 | 76 |
|
77 | 77 | jobs: |
| 78 | + # PRs from forks require approval, specifically with the "pull_request_target" event as it contains repo secrets. |
| 79 | + check-if-requires-approval: |
| 80 | + runs-on: ubuntu-latest |
| 81 | + outputs: |
| 82 | + requires_approval: ${{ steps.set-output.outputs.requires_approval }} |
| 83 | + steps: |
| 84 | + - name: Set requires approval output |
| 85 | + id: set-output |
| 86 | + run: | |
| 87 | + if [[ "${{ github.event_name }}" =~ ^pull_request && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then |
| 88 | + echo "requires_approval=true" >> $GITHUB_OUTPUT |
| 89 | + else |
| 90 | + echo "requires_approval=false" >> $GITHUB_OUTPUT |
| 91 | + fi |
| 92 | +
|
78 | 93 | test: |
79 | 94 | runs-on: ubuntu-latest |
80 | | - environment: elementary_test_env # This is a github environment (not to be confused with env vars) |
| 95 | + needs: [check-if-requires-approval] |
| 96 | + environment: ${{ (needs.check-if-requires-approval.outputs.requires_approval == 'true' && 'elementary_test_env') || '' }} |
81 | 97 | defaults: |
82 | 98 | run: |
83 | 99 | working-directory: elementary |
@@ -188,10 +204,16 @@ jobs: |
188 | 204 | --project-dir "${{ env.DBT_PKG_INTEG_TESTS_DIR }}" |
189 | 205 | --project-profile-target "${{ inputs.warehouse-type }}" |
190 | 206 |
|
| 207 | + - name: Set report artifact name |
| 208 | + id: set_report_artifact_name |
| 209 | + run: | |
| 210 | + ARTIFACT_NAME=$(echo "report_${{ inputs.warehouse-type }}_${BRANCH_NAME}_dbt_${{ inputs.dbt-version || '' }}.html" | awk '{print tolower($0)}' | sed 's#[":/\\<>|*?-]#_#g') |
| 211 | + echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" |
| 212 | +
|
191 | 213 | - name: Upload report artifact |
192 | 214 | uses: actions/upload-artifact@v4 |
193 | 215 | with: |
194 | | - name: report_${{ inputs.warehouse-type }}_${{ env.BRANCH_NAME }}_dbt_${{ inputs.dbt-version }}.html |
| 216 | + name: ${{ steps.set_report_artifact_name.outputs.artifact_name }} |
195 | 217 | path: elementary/edr_target/elementary_report.html |
196 | 218 |
|
197 | 219 | - name: Write GCS keyfile |
@@ -223,11 +245,17 @@ jobs: |
223 | 245 | --azure-container-name reports |
224 | 246 | --update-bucket-website true |
225 | 247 |
|
| 248 | + - name: Set artifact name |
| 249 | + id: set_artifact_name |
| 250 | + run: | |
| 251 | + ARTIFACT_NAME=$(echo "edr_${{ inputs.warehouse-type }}_${BRANCH_NAME}_dbt_${{ inputs.dbt-version || '' }}.log" | awk '{print tolower($0)}' | sed 's#[":/\\<>|*?-]#_#g') |
| 252 | + echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" |
| 253 | +
|
226 | 254 | - name: Upload edr log |
227 | 255 | if: ${{ always() }} |
228 | 256 | uses: actions/upload-artifact@v4 |
229 | 257 | with: |
230 | | - name: edr_${{ inputs.warehouse-type }}_${{ env.BRANCH_NAME }}_dbt_${{ inputs.dbt-version }}.log |
| 258 | + name: ${{ steps.set_artifact_name.outputs.artifact_name }} |
231 | 259 | path: elementary/edr_target/edr.log |
232 | 260 |
|
233 | 261 | - name: Run Python package e2e tests |
|
0 commit comments