Skip to content

Commit 7ead479

Browse files
feat(): Setup CodeArtifact (#1802)
1 parent f106f28 commit 7ead479

7 files changed

Lines changed: 203 additions & 11 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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"

.github/workflows/codestyle.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Codestyle checking
22

33
on:
44
workflow_call:
5+
secrets:
6+
AWS_CODEARTIFACT_READ_ACCESS_KEY:
7+
required: true
8+
AWS_CODEARTIFACT_READ_ACCESS_SECRET:
9+
required: true
510
workflow_dispatch:
611

712
jobs:
@@ -15,6 +20,11 @@ jobs:
1520
with:
1621
python-version: '3.9'
1722
cache: 'poetry'
23+
- name: Setup CodeArtifact auth for Poetry
24+
uses: ./.github/actions/setup-codeartifact-poetry-auth
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_KEY }}
27+
aws-secret-access-key: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_SECRET }}
1828
- name: Install black
1929
run: poetry install
2030
- name: Run black
@@ -30,6 +40,11 @@ jobs:
3040
with:
3141
python-version: '3.9'
3242
cache: 'poetry'
43+
- name: Setup CodeArtifact auth for Poetry
44+
uses: ./.github/actions/setup-codeartifact-poetry-auth
45+
with:
46+
aws-access-key-id: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_KEY }}
47+
aws-secret-access-key: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_SECRET }}
3348
- name: Install isort
3449
run: poetry install
3550
- name: Check isort version
@@ -47,6 +62,11 @@ jobs:
4762
with:
4863
python-version: '3.9'
4964
cache: 'poetry'
65+
- name: Setup CodeArtifact auth for Poetry
66+
uses: ./.github/actions/setup-codeartifact-poetry-auth
67+
with:
68+
aws-access-key-id: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_KEY }}
69+
aws-secret-access-key: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_SECRET }}
5070
- name: Install dependencies
5171
run: poetry install
5272
- name: Run pylint

.github/workflows/pypi-publish.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ jobs:
326326
with:
327327
python-version: '3.9'
328328
cache: 'poetry'
329+
- name: Setup CodeArtifact auth for Poetry
330+
uses: ./.github/actions/setup-codeartifact-poetry-auth
331+
with:
332+
aws-access-key-id: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_KEY }}
333+
aws-secret-access-key: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_SECRET }}
334+
aws-region: us-east-1
335+
domain: flexcompute
336+
domain-owner: "625554095313"
329337
- name: Install dependencies
330338
run: poetry install
331339
- name: Pump version number

.github/workflows/test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ on:
77
pull_request:
88
types: [ opened, synchronize, reopened, ready_for_review ]
99
workflow_call:
10+
secrets:
11+
AWS_CODEARTIFACT_READ_ACCESS_KEY:
12+
required: true
13+
AWS_CODEARTIFACT_READ_ACCESS_SECRET:
14+
required: true
1015

1116
jobs:
1217
code-style:
1318
uses: ./.github/workflows/codestyle.yml
19+
secrets: inherit
1420
testing:
1521
needs: code-style
1622
name: test ${{ matrix.python-version }} - ${{ matrix.platform }}
@@ -46,6 +52,12 @@ jobs:
4652
virtualenvs-in-project: true
4753
virtualenvs-create: true
4854

55+
- name: Setup CodeArtifact auth for Poetry
56+
uses: ./.github/actions/setup-codeartifact-poetry-auth
57+
with:
58+
aws-access-key-id: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_KEY }}
59+
aws-secret-access-key: ${{ secrets.AWS_CODEARTIFACT_READ_ACCESS_SECRET }}
60+
4961
- name: Install dependencies
5062
run: poetry install
5163

0 commit comments

Comments
 (0)