|
| 1 | +name: Setup CodeArtifact Poetry Auth |
| 2 | +description: Configure AWS credentials, fetch CodeArtifact token, and set Poetry auth env vars. |
| 3 | + |
| 4 | +inputs: |
| 5 | + aws-access-key-id: |
| 6 | + description: AWS access key id for CodeArtifact access. |
| 7 | + required: true |
| 8 | + aws-secret-access-key: |
| 9 | + description: AWS secret access key for CodeArtifact access. |
| 10 | + required: true |
| 11 | + aws-region: |
| 12 | + description: AWS region of the CodeArtifact domain. |
| 13 | + required: false |
| 14 | + default: us-east-1 |
| 15 | + domain: |
| 16 | + description: CodeArtifact domain name. |
| 17 | + required: false |
| 18 | + default: flexcompute |
| 19 | + domain-owner: |
| 20 | + description: AWS account id that owns the CodeArtifact domain. |
| 21 | + required: false |
| 22 | + default: "625554095313" |
| 23 | + |
| 24 | +outputs: |
| 25 | + token: |
| 26 | + description: CodeArtifact authorization token. |
| 27 | + value: ${{ steps.get-token.outputs.token }} |
| 28 | + |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + steps: |
| 32 | + - name: Configure AWS credentials |
| 33 | + uses: aws-actions/configure-aws-credentials@v4 |
| 34 | + with: |
| 35 | + aws-access-key-id: ${{ inputs.aws-access-key-id }} |
| 36 | + aws-secret-access-key: ${{ inputs.aws-secret-access-key }} |
| 37 | + aws-region: ${{ inputs.aws-region }} |
| 38 | + |
| 39 | + - name: Get CodeArtifact token and set Poetry env |
| 40 | + id: get-token |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + TOKEN=$(aws codeartifact get-authorization-token \ |
| 44 | + --domain "${{ inputs.domain }}" \ |
| 45 | + --domain-owner "${{ inputs.domain-owner }}" \ |
| 46 | + --region "${{ inputs.aws-region }}" \ |
| 47 | + --query authorizationToken \ |
| 48 | + --output text) |
| 49 | + echo "::add-mask::$TOKEN" |
| 50 | + echo "token=$TOKEN" >> "$GITHUB_OUTPUT" |
| 51 | + echo "POETRY_HTTP_BASIC_CODEARTIFACT_USERNAME=aws" >> "$GITHUB_ENV" |
| 52 | + echo "POETRY_HTTP_BASIC_CODEARTIFACT_PASSWORD=$TOKEN" >> "$GITHUB_ENV" |
0 commit comments