|
| 1 | +name: make run-prod (or custom) |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 13 * * 3' |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + command: |
| 9 | + description: The Makefile command to run. Default = make run-prod |
| 10 | + type: string |
| 11 | + |
| 12 | +env: |
| 13 | + COMMAND: ${{ inputs.command || 'make run-prod' }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + run-command: |
| 17 | + permissions: |
| 18 | + id-token: write # This is required for requesting the JWT |
| 19 | + contents: read # This is required for actions/checkout |
| 20 | + environment: production |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout Repo |
| 25 | + id: checkout_repo |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + # From: https://stackoverflow.com/a/58035262/2097171 |
| 29 | + - name: Extract branch name |
| 30 | + shell: bash |
| 31 | + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT |
| 32 | + id: get-branch |
| 33 | + |
| 34 | + # From: https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers#requesting-the-jwt-using-the-actions-core-toolkit |
| 35 | + - name: Install OIDC Client from Core Package |
| 36 | + run: npm install @actions/core@1.6.0 @actions/http-client |
| 37 | + - name: Get Id Token |
| 38 | + uses: actions/github-script@v7 |
| 39 | + id: idtoken |
| 40 | + with: |
| 41 | + script: | |
| 42 | + const coredemo = require('@actions/core') |
| 43 | + const id_token = await coredemo.getIDToken('api://AzureADTokenExchange') |
| 44 | + coredemo.setOutput('id_token', id_token) |
| 45 | +
|
| 46 | +
|
| 47 | + - name: Run command |
| 48 | + uses: CDCgov/cfa-actions/runner-action@v1.4.0 |
| 49 | + with: |
| 50 | + github_app_id: ${{ secrets.CDCENT_ACTOR_APP_ID }} |
| 51 | + github_app_pem: ${{ secrets.CDCENT_ACTOR_APP_PEM }} |
| 52 | + wait_for_completion: true |
| 53 | + print_logs: true |
| 54 | + script: | |
| 55 | + echo "Logging into Azure CLI" |
| 56 | + az login --service-principal \ |
| 57 | + --username ${{ secrets.AZURE_NNHT_SP_CLIENT_ID }} \ |
| 58 | + --tenant ${{ secrets.TENANT_ID }} \ |
| 59 | + --federated-token ${{ steps.idtoken.outputs.id_token }} \ |
| 60 | + --output none |
| 61 | +
|
| 62 | + CURRENT_BRANCH="${{ steps.get-branch.outputs.branch }}" |
| 63 | + echo "Cloning repo at branch '$CURRENT_BRANCH'" |
| 64 | + git clone -b "$CURRENT_BRANCH" https://github.com/${{ github.repository }}.git |
| 65 | + cd cfa-epinow2-pipeline |
| 66 | +
|
| 67 | + echo 'Running command: "${{ env.COMMAND }}"' |
| 68 | + ${{ env.COMMAND }} |
0 commit comments