|
| 1 | +name: IPA Validation Metrics Release |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + secrets: # all secrets are passed explicitly in this workflow |
| 5 | +# aws_access_key: |
| 6 | +# required: true |
| 7 | +# aws_secret_key: |
| 8 | +# required: true |
| 9 | +# aws_s3_bucket_prefix: |
| 10 | +# required: true |
| 11 | + api_bot_pat: |
| 12 | + required: true |
| 13 | + IPA_S3_BUCKET_DW_STAGING_USERNAME: |
| 14 | + required: true |
| 15 | + IPA_S3_BUCKET_DW_STAGING_PASSWORD: |
| 16 | + required: true |
| 17 | + IPA_S3_BUCKET_DW_STAGING_PREFIX: |
| 18 | + required: true |
| 19 | +# inputs: |
| 20 | +# env: |
| 21 | +# description: 'Environment for the FOAS to use for IPA metrics collection' |
| 22 | +# required: true |
| 23 | +# type: string |
| 24 | + workflow_dispatch: |
| 25 | + |
| 26 | +permissions: |
| 27 | + issues: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + release-IPA-metrics: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Get Previous Run Date and Status |
| 37 | + id: get_previous_status |
| 38 | + uses: actions/github-script@v7 |
| 39 | + with: |
| 40 | + github-token: ${{ secrets.api_bot_pat }} |
| 41 | + script: | |
| 42 | + const script = require('tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js') |
| 43 | + const shouldRunRelease = await getShouldRunMetricsRelease({github, context}) |
| 44 | + return shouldRunRelease |
| 45 | +
|
| 46 | + - name: Skip Metric Collection Job |
| 47 | + if: ${{steps.get_previous_status.outputs.result == 'false' }} |
| 48 | + run: echo "Skipping IPA metrics release!" |
| 49 | + |
| 50 | + - name: Setup Node |
| 51 | + if: ${{steps.get_previous_status.outputs.result == 'true' }} |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: '20.x' |
| 55 | + cache: 'npm' |
| 56 | + |
| 57 | + - name: Install npm dependencies |
| 58 | + if: ${{steps.get_previous_status.outputs.result == 'true' }} |
| 59 | + run: npm install |
| 60 | + |
| 61 | + - name: Download openapi-foas |
| 62 | + if: ${{steps.get_previous_status.outputs.result == 'true' }} |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: openapi-foas-dev # TODO: Change to passed input env |
| 66 | + github-token: ${{ secrets.api_bot_pat }} |
| 67 | + run-id: ${{ github.run_id }} |
| 68 | + |
| 69 | + - name: Run Metric Collection Job |
| 70 | + if: ${{steps.get_previous_status.outputs.result == 'true' }} |
| 71 | + working-directory: ./tools/spectral/ipa/metrics/scripts |
| 72 | + run: node runMetricCollection.js ../../../../../openapi-foas.json |
| 73 | + |
| 74 | + - name: Dump Metric Collection Job Data to S3 |
| 75 | + if: ${{steps.get_previous_status.outputs.result == 'true' }} |
| 76 | + env: |
| 77 | + AWS_ACCESS_KEY_ID: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME }} # TODO: Change to passed secret |
| 78 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD }} # TODO: Change to passed secret |
| 79 | + S3_BUCKET_PREFIX: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX }} # TODO: Change to passed secret |
| 80 | + working-directory: ./tools/spectral/ipa/metrics/scripts |
| 81 | + run: node dataDump.js ../../../../../openapi-foas.json |
0 commit comments