Skip to content

Commit 1c52c05

Browse files
author
Jonathan Wenger
committed
Retrieve Bearer token in pipelne.
1 parent 46624f5 commit 1c52c05

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

.github/workflows/python-publish.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@ on:
66

77
jobs:
88
deploy:
9-
109
runs-on: ubuntu-latest
1110

1211
steps:
13-
- uses: actions/checkout@v2
14-
- name: Set up Python
15-
uses: actions/setup-python@v2
16-
with:
17-
python-version: '3.x'
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install build
22-
pip install -r ./requirements.txt
23-
pip install -r ./test-requirements.txt
24-
- name: Build package
25-
run: python -m build
26-
- name: Test package
27-
run: pytest -s -v --cov=Avalara.SDK --username=${{ secrets.API_USERNAME }} --password=${{ secrets.API_PASSWORD }}
28-
- name: Publish package
29-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
30-
with:
31-
user: __token__
32-
password: ${{ secrets.PYPI_API_TOKEN }}
12+
- uses: actions/checkout@v2
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: "3.x"
17+
- name: Retrieve bearer token
18+
id: get_bearer_token
19+
run: |
20+
response=$(curl -X POST ${{secrets.OKTA_ACCESS_TOKEN_URL}}/connect/token \
21+
-H "Content-Type: application/x-www-form-urlencoded" \
22+
-d "grant_type=client_credentials&client_id=${{secrets.OKTA_CLIENT_ID}}&client_secret=${{secrets.OKTA_CLIENT_SECRET}}")
23+
token=$(echo $response | jq -r '.access_token')
24+
echo "BEARER_TOKEN=${token}" >> $GITHUB_ENV
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build
29+
pip install -r ./requirements.txt
30+
pip install -r ./test-requirements.txt
31+
- name: Build package
32+
run: python -m build
33+
- name: Test package
34+
run: pytest -s -v --cov=Avalara.SDK --username=${{ secrets.API_USERNAME }} --password=${{ secrets.API_PASSWORD }}
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)