Skip to content

Commit 68905c0

Browse files
Merge pull request #26 from hellosign/fetch-ci-secrets-from-aws-sm
Fetch ci secrets from aws sm
2 parents 21105de + d1e5506 commit 68905c0

2 files changed

Lines changed: 27 additions & 46 deletions

File tree

‎.github/workflows/github-actions.yml‎

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# This workflow will build the project, run integration tests, and release.
2-
# Because secrets are not available on external forks, this job is expected to fail
3-
# on external pull requests.
4-
5-
# publishing instructions from
6-
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
# Secret-backed jobs fetch credentials from AWS Secrets Manager using GitHub OIDC.
3+
# PyPI uploads use trusted publishing (GitHub OIDC), not API tokens.
74

85
name: Build, Check, Publish
96

@@ -16,56 +13,42 @@ on:
1613
jobs:
1714
build:
1815
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: read
1919
steps:
2020
- name: Checkout Repo
2121
uses: actions/checkout@v3
2222

23+
- name: Configure AWS credentials for Docker Hub secrets (OIDC)
24+
if: github.event_name != 'pull_request'
25+
uses: aws-actions/configure-aws-credentials@v6
26+
with:
27+
role-to-assume: arn:aws:iam::301904545275:role/oidc-github-hellosign-dropbox-sign-python-branch-main
28+
aws-region: us-west-2
29+
30+
- name: Get Docker Hub secrets from AWS Secrets Manager
31+
if: github.event_name != 'pull_request'
32+
uses: aws-actions/aws-secretsmanager-get-secrets@v3
33+
with:
34+
secret-ids: |
35+
DOCKER_USERNAME,github-actions/hellosign/shared/docker-username
36+
DOCKER_TOKEN,github-actions/hellosign/shared/docker-token
37+
parse-json-secrets: false
38+
2339
- name: Build SDK
2440
run: ./run-build
25-
env:
26-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
27-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
2841

2942
- name: Ensure no changes in Generated Code
3043
run: ./bin/check-clean-git-status
3144

32-
# This job runs on pull requests
33-
# Publishes to test.pypi.org, useful as a dry run
34-
# Step still passes even if package version was already uploaded
35-
publish-test:
36-
runs-on: ubuntu-latest
37-
if: >-
38-
github.repository == 'hellosign/dropbox-sign-python'
39-
&& github.ref != 'refs/heads/main'
40-
&& github.event_name == 'pull_request'
41-
needs: [ build ]
42-
steps:
43-
- name: Checkout
44-
uses: actions/checkout@v3
45-
46-
- name: Set up Python 3.10
47-
uses: actions/setup-python@v3
48-
with:
49-
python-version: "3.10"
50-
51-
- name: Install pypa/build
52-
run: python -m pip install build --user
53-
54-
- name: Build a binary wheel and a source tarball
55-
run: python -m build --sdist --wheel --outdir dist/ .
56-
57-
- name: Publish distribution to Test PyPI
58-
uses: pypa/gh-action-pypi-publish@release/v1
59-
with:
60-
password: ${{ secrets.PYPI_TEST_API_KEY }}
61-
repository_url: https://test.pypi.org/legacy/
62-
skip_existing: true
63-
verbose: true
64-
6545
# This job runs on merging to "main" branch
66-
# Builds and publishes package to pypi.org
46+
# Builds and publishes package to pypi.org with trusted publishing
6747
publish-prod:
6848
runs-on: ubuntu-latest
49+
permissions:
50+
contents: read
51+
id-token: write
6952
if: >-
7053
github.repository == 'hellosign/dropbox-sign-python'
7154
&& github.ref == 'refs/heads/main'
@@ -86,10 +69,8 @@ jobs:
8669
- name: Build a binary wheel and a source tarball
8770
run: python -m build --sdist --wheel --outdir dist/ .
8871

89-
- name: Publish distribution to PyPI
72+
- name: Publish package with trusted publishing
9073
uses: pypa/gh-action-pypi-publish@release/v1
91-
with:
92-
password: ${{ secrets.PYPI_API_KEY }}
9374

9475
# This job runs on merging to "main" branch
9576
# Creates a new tag using the value in the VERSION file

‎run-build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -e
77
DIR=$(cd `dirname $0` && pwd)
88
WORKING_DIR="/app/python"
99

10-
if [[ -n "$GITHUB_ACTIONS" ]]; then
10+
if [[ -n "$GITHUB_ACTIONS" && -n "${DOCKER_USERNAME:-}" && -n "${DOCKER_TOKEN:-}" ]]; then
1111
printf "\nLogging in to docker.com ...\n"
1212
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
1313
fi

0 commit comments

Comments
 (0)