|
| 1 | +name: Set ACL Permissions Template |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + environment: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + default: "dev" |
| 10 | + description: "Specifies the environment of the deployment." |
| 11 | + storage_account_name: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + description: "Specifies the name of the storage account." |
| 15 | + storage_container_name: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + description: "Specifies the name of the storage account container name." |
| 19 | + storage_container_path: |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + description: "Specifies the path within the storage account container." |
| 23 | + user_object_id: |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + description: "Specifies the object id of the identity that should be granted access." |
| 27 | + acl_permissions: |
| 28 | + required: true |
| 29 | + type: string |
| 30 | + description: "Specifies the acl permissions to be granted to the identity (e.g. 'rwx')." |
| 31 | + secrets: |
| 32 | + TENANT_ID: |
| 33 | + required: true |
| 34 | + description: "Specifies the tenant id of the deployment." |
| 35 | + SUBSCRIPTION_ID: |
| 36 | + required: true |
| 37 | + description: "Specifies the subscription id of the deployment." |
| 38 | + CLIENT_ID: |
| 39 | + required: true |
| 40 | + description: "Specifies the client id." |
| 41 | + CLIENT_SECRET: |
| 42 | + required: true |
| 43 | + description: "Specifies the client secret." |
| 44 | + |
| 45 | +jobs: |
| 46 | + exec: |
| 47 | + name: Run Az CLI Command |
| 48 | + runs-on: [self-hosted, linux, adp] |
| 49 | + continue-on-error: false |
| 50 | + environment: "${{ inputs.environment }}" |
| 51 | + |
| 52 | + steps: |
| 53 | + # Login to Azure |
| 54 | + - name: Azure Login |
| 55 | + id: azure_login |
| 56 | + uses: azure/login@v1 |
| 57 | + with: |
| 58 | + creds: '{"clientId":"${{ secrets.CLIENT_ID }}","clientSecret":"${{ secrets.CLIENT_SECRET }}","subscriptionId":"${{ secrets.SUBSCRIPTION_ID }}","tenantId":"${{ secrets.TENANT_ID }}"}' |
| 59 | + |
| 60 | + # Grant Access - ACL |
| 61 | + - name: Grant Access - ACL |
| 62 | + id: access_acl |
| 63 | + run: | |
| 64 | + echo "Set Azure Context" |
| 65 | + az account set -s "${{ secrets.SUBSCRIPTION_ID }}" |
| 66 | +
|
| 67 | + echo "Set ACL" |
| 68 | + az storage fs access set \ |
| 69 | + --acl "user:$USER_OBJECT_ID:$ACL_PERMISSIONS" \ |
| 70 | + --path $STORAGE_CONTAINER_PATH \ |
| 71 | + --file-system $STORAGE_CONTAINER_NAME \ |
| 72 | + --account-name $STORAGE_ACCOUNT_NAME \ |
| 73 | + --auth-mode login |
| 74 | + env: |
| 75 | + USER_OBJECT_ID: ${{ inputs.user_object_id }} |
| 76 | + ACL_PERMISSIONS: ${{ inputs.acl_permissions }} |
| 77 | + STORAGE_ACCOUNT_NAME: ${{ inputs.storage_account_name }} |
| 78 | + STORAGE_CONTAINER_NAME: ${{ inputs.storage_container_name }} |
| 79 | + STORAGE_CONTAINER_PATH: ${{ inputs.storage_container_path }} |
| 80 | + |
| 81 | + # Log out from Azure |
| 82 | + - name: Log out from Azure |
| 83 | + id: azure_logout |
| 84 | + run: | |
| 85 | + az logout |
0 commit comments