|
| 1 | +name: Create DPC Portal Invite |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + env: |
| 7 | + description: AWS environment to check |
| 8 | + required: true |
| 9 | + type: 'string' |
| 10 | + default: 'test' |
| 11 | + org_npi: |
| 12 | + description: Organization NPI |
| 13 | + required: true |
| 14 | + type: 'string' |
| 15 | + given_name: |
| 16 | + description: Given name |
| 17 | + required: true |
| 18 | + type: 'string' |
| 19 | + family_name: |
| 20 | + description: Family name |
| 21 | + required: true |
| 22 | + type: 'string' |
| 23 | + email: |
| 24 | + description: Email address |
| 25 | + required: true |
| 26 | + type: 'string' |
| 27 | + |
| 28 | +permissions: |
| 29 | + id-token: write |
| 30 | + contents: read |
| 31 | + |
| 32 | +jobs: |
| 33 | + create-portal-invite: |
| 34 | + name: Create DPC Portal Invite |
| 35 | + runs-on: codebuild-dpc-app-${{github.run_id}}-${{github.run_attempt}} |
| 36 | + steps: |
| 37 | + - name: Assert Ownership |
| 38 | + run: sudo chmod -R 777 . |
| 39 | + - name: Checkout code |
| 40 | + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 41 | + with: |
| 42 | + path: dpc-app |
| 43 | + - name: AWS Credentials (non-prod) |
| 44 | + if: ${{ inputs.env == 'dev' || inputs.env == 'test' }} |
| 45 | + uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1 |
| 46 | + with: |
| 47 | + aws-region: ${{ vars.AWS_REGION }} |
| 48 | + role-to-assume: arn:aws:iam::${{ secrets.NON_PROD_ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-${{ inputs.env }}-github-actions |
| 49 | + - name: AWS Credentials (prod) |
| 50 | + if: ${{ inputs.env == 'sandbox' || inputs.env == 'prod' }} |
| 51 | + uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1 |
| 52 | + with: |
| 53 | + aws-region: ${{ vars.AWS_REGION }} |
| 54 | + role-to-assume: arn:aws:iam::${{ secrets.PROD_ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-${{ inputs.env }}-github-actions |
| 55 | + - name: Install AWS Session Manager Plugin |
| 56 | + run: | |
| 57 | + sudo dnf install -y https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm |
| 58 | + - name: Set cluster and service names |
| 59 | + run: | |
| 60 | + echo "CLUSTER_NAME=dpc-${{ inputs.env }}-frontend" >> $GITHUB_ENV |
| 61 | + echo "SERVICE_NAME=dpc-${{ inputs.env }}-web-portal-v9" >> $GITHUB_ENV |
| 62 | + - name: Start temp service |
| 63 | + run: ./dpc-app/scripts/start_temp_service.sh $CLUSTER_NAME $SERVICE_NAME |
| 64 | + - name: Generate invite link |
| 65 | + env: |
| 66 | + RAILS_CMD: rails dpc:invite_ao INVITE=${{ inputs.given_name }},${{ inputs.family_name }},${{ inputs.email }},${{ inputs.org_npi }} |
| 67 | + run: | |
| 68 | + aws ecs execute-command \ |
| 69 | + --region ${{ vars.AWS_REGION }} \ |
| 70 | + --cluster $CLUSTER_NAME \ |
| 71 | + --task $NEW_TASK_ID \ |
| 72 | + --container $NEW_CONTAINER_NAME \ |
| 73 | + --command "$RAILS_CMD " \ |
| 74 | + --interactive |
| 75 | + - name: Delete temp service |
| 76 | + if: always() |
| 77 | + run: | |
| 78 | + aws ecs delete-service \ |
| 79 | + --force \ |
| 80 | + --cluster $CLUSTER_NAME \ |
| 81 | + --service $NEW_SERVICE_NAME |
| 82 | + - name: Deregister the task definition |
| 83 | + if: always() |
| 84 | + run: | |
| 85 | + TASK_DEF_ARN=$(aws ecs describe-tasks --cluster "$CLUSTER_NAME" --tasks "$NEW_TASK_ARN" | jq -r '.tasks[].taskDefinitionArn') |
| 86 | + aws ecs deregister-task-definition --task-definition $TASK_DEF_ARN |
0 commit comments