22# (number of adoptions, violations and exceptions) and upload the data to an S3 bucket.
33name : IPA Validation Metrics Release
44on :
5- workflow_call :
6- secrets : # all secrets are passed explicitly in this workflow
7- aws_access_key :
8- required : true
9- aws_secret_key :
10- required : true
11- aws_s3_bucket_prefix :
12- required : true
13- api_bot_pat :
14- required : true
15- inputs :
16- env :
17- description : ' Environment for the FOAS to use for IPA metrics collection'
18- required : true
19- type : string
5+ schedule :
6+ - cron : ' 0 22 * * *' # Runs daily at 22:00 UTC (10 PM UTC)
207 workflow_dispatch :
21-
228permissions :
239 issues : write
10+ env :
11+ NODE_VERSION : ' 20.x'
12+ WORKING_DIR : ./tools/spectral/ipa/metrics/scripts
13+ RELEASE_ENV : ' dev'
2414
2515jobs :
26- # Checks the last workflow run, and decides whether the IPA release metrics should be uploaded or
27- # skipped. The release-IPA-metrics job only runs if the last release was not today and did not fail.
28- pre-IPA-metrics-release-checks :
29- name : IPA Metrics Release Pre-Checks
30- runs-on : ubuntu-latest
31- outputs :
32- should_run_release : ${{ steps.get_previous_status.outputs.result }}
33- steps :
34- - name : Checkout
35- uses : actions/checkout@v4
36-
37- - name : Get Previous Run Date and Status
38- id : get_previous_status
39- uses : actions/github-script@v7
40- with :
41- github-token : ${{ secrets.api_bot_pat }}
42- script : |
43- const { default: getShouldRunMetricsRelease } = await import('${{ github.workspace }}/tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js')
44- const shouldRunRelease = await getShouldRunMetricsRelease({github, context}).catch((error) => {
45- console.error(error.message);
46- process.exit(1)
47- })
48- return shouldRunRelease
49-
5016 # Generates and uploads the IPA validation metrics to S3
5117 release-IPA-metrics :
5218 name : Release IPA Validation Metrics
53- needs : [pre-IPA-metrics-release-checks]
54- if : ${{ needs.pre-IPA-metrics-release-checks.outputs.should_run_release == 'true' }}
5519 runs-on : ubuntu-latest
5620 steps :
5721 - name : Checkout
6024 - name : Setup Node
6125 uses : actions/setup-node@v4
6226 with :
63- node-version : ' 20.x '
27+ node-version : ${{ env.NODE_VERSION }}
6428 cache : ' npm'
6529
6630 - name : Install npm dependencies
@@ -69,18 +33,29 @@ jobs:
6933 - name : Download openapi-foas
7034 uses : actions/download-artifact@v4
7135 with :
72- name : openapi-foas-${{ inputs. env }}
73- github-token : ${{ secrets.api_bot_pat }}
36+ name : openapi-foas-${{ env.RELEASE_ENV }}
37+ github-token : ${{ secrets.API_BOT_PAT }}
7438 run-id : ${{ github.run_id }}
7539
7640 - name : Run Metric Collection Job
77- working-directory : ./tools/spectral/ipa/metrics/scripts
41+ working-directory : ${{ env.WORKING_DIR }}
7842 run : node runMetricCollection.js ../../../../../openapi-foas.json
7943
8044 - name : Dump Metric Collection Job Data to S3
8145 env :
82- AWS_ACCESS_KEY_ID : ${{ secrets.aws_access_key }}
83- AWS_SECRET_ACCESS_KEY : ${{ secrets.aws_secret_key }}
84- S3_BUCKET_PREFIX : ${{ secrets.aws_s3_bucket_prefix }}
85- working-directory : ./tools/spectral/ipa/metrics/scripts
46+ AWS_ACCESS_KEY_ID : ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME }}
47+ AWS_SECRET_ACCESS_KEY : ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD }}
48+ S3_BUCKET_PREFIX : ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX }}
49+ working-directory : ${{ env.WORKING_DIR }}
8650 run : node dataDump.js
51+
52+ failure-handler :
53+ name : Failure Handler
54+ needs : [ release-IPA-metrics ]
55+ if : ${{ always() && contains(needs.*.result, 'failure') }}
56+ uses : ./.github/workflows/failure-handler.yml
57+ with :
58+ env : ${{ env.RELEASE_ENV }}
59+ release_name : " OpenAPI Spec"
60+ secrets :
61+ jira_api_token : ${{ secrets.JIRA_API_TOKEN }}
0 commit comments