Skip to content

Commit 7cbca50

Browse files
Fetch Docker secrets from AWS Secrets Manager (#565)
1 parent 8f19bc6 commit 7cbca50

9 files changed

Lines changed: 57 additions & 54 deletions

File tree

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
1-
on: [push]
1+
on:
2+
push:
3+
branches: [ main ]
4+
pull_request:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
211
jobs:
312
openapi-spec-build:
413
runs-on: ubuntu-latest
514
steps:
615
- name: Checkout Repo
716
uses: actions/checkout@v3
817

18+
- &configure-aws
19+
name: Configure AWS credentials for Docker Hub secrets (OIDC)
20+
if: github.event_name != 'pull_request'
21+
uses: aws-actions/configure-aws-credentials@v6
22+
with:
23+
role-to-assume: arn:aws:iam::301904545275:role/oidc-github-hellosign-hellosign-openapi-branch-main
24+
aws-region: us-west-2
25+
26+
- &get-docker-secrets
27+
name: Get Docker Hub secrets from AWS Secrets Manager
28+
if: github.event_name != 'pull_request'
29+
uses: aws-actions/aws-secretsmanager-get-secrets@v3
30+
with:
31+
secret-ids: |
32+
DOCKER_USERNAME,github-actions/hellosign/shared/docker-username
33+
DOCKER_TOKEN,github-actions/hellosign/shared/docker-token
34+
parse-json-secrets: false
35+
936
- name: Build OpenAPI Spec
1037
run: ./build
11-
env:
12-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
13-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
1438

1539
- name: Ensure no changes in Generated Code
1640
run: ./bin/check-clean-git-status oas
@@ -21,17 +45,14 @@ jobs:
2145
- name: Checkout Repo
2246
uses: actions/checkout@v3
2347

48+
- *configure-aws
49+
- *get-docker-secrets
50+
2451
- name: Build OpenAPI Spec
2552
run: ./build
26-
env:
27-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
28-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
2953

3054
- name: Build PHP SDK
3155
run: ./generate-sdks -t php
32-
env:
33-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
34-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
3556

3657
- name: Ensure no changes in Generated Code
3758
run: ./bin/check-clean-git-status php
@@ -42,17 +63,14 @@ jobs:
4263
- name: Checkout Repo
4364
uses: actions/checkout@v3
4465

66+
- *configure-aws
67+
- *get-docker-secrets
68+
4569
- name: Build OpenAPI Spec
4670
run: ./build
47-
env:
48-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
49-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
5071

5172
- name: Build Python SDK
5273
run: ./generate-sdks -t python
53-
env:
54-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
55-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
5674

5775
- name: Ensure no changes in Generated Code
5876
run: ./bin/check-clean-git-status python
@@ -63,17 +81,14 @@ jobs:
6381
- name: Checkout Repo
6482
uses: actions/checkout@v3
6583

84+
- *configure-aws
85+
- *get-docker-secrets
86+
6687
- name: Build OpenAPI Spec
6788
run: ./build
68-
env:
69-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
70-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
7189

7290
- name: Build Ruby SDK
7391
run: ./generate-sdks -t ruby
74-
env:
75-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
76-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
7792

7893
- name: Ensure no changes in Generated Code
7994
run: ./bin/check-clean-git-status ruby
@@ -84,17 +99,14 @@ jobs:
8499
- name: Checkout Repo
85100
uses: actions/checkout@v3
86101

102+
- *configure-aws
103+
- *get-docker-secrets
104+
87105
- name: Build OpenAPI Spec
88106
run: ./build
89-
env:
90-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
91-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
92107

93108
- name: Build NodeJs SDK
94109
run: ./generate-sdks -t node
95-
env:
96-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
97-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
98110

99111
- name: Ensure no changes in Generated Code
100112
run: ./bin/check-clean-git-status node
@@ -105,17 +117,14 @@ jobs:
105117
- name: Checkout Repo
106118
uses: actions/checkout@v3
107119

120+
- *configure-aws
121+
- *get-docker-secrets
122+
108123
- name: Build OpenAPI Spec
109124
run: ./build
110-
env:
111-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
112-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
113125

114126
- name: Build Java SDK
115127
run: ./generate-sdks -t java-v1
116-
env:
117-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
118-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
119128

120129
- name: Ensure no changes in Generated Code
121130
run: ./bin/check-clean-git-status java-v1
@@ -126,17 +135,14 @@ jobs:
126135
- name: Checkout Repo
127136
uses: actions/checkout@v3
128137

138+
- *configure-aws
139+
- *get-docker-secrets
140+
129141
- name: Build OpenAPI Spec
130142
run: ./build
131-
env:
132-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
133-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
134143

135144
- name: Build Java SDK
136145
run: ./generate-sdks -t java-v2
137-
env:
138-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
139-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
140146

141147
- name: Ensure no changes in Generated Code
142148
run: ./bin/check-clean-git-status java-v2
@@ -147,17 +153,14 @@ jobs:
147153
- name: Checkout Repo
148154
uses: actions/checkout@v3
149155

156+
- *configure-aws
157+
- *get-docker-secrets
158+
150159
- name: Build OpenAPI Spec
151160
run: ./build
152-
env:
153-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
154-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
155161

156162
- name: Build DotNet SDK
157163
run: ./generate-sdks -t dotnet
158-
env:
159-
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
160-
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
161164

162165
- name: Ensure no changes in Generated Code
163166
run: ./bin/check-clean-git-status dotnet

bin/php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DIR=$(cd `dirname $0` && pwd)
88
ROOT_DIR="${DIR}/.."
99
WORKING_DIR="/app/openapi"
1010

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

sdks/dotnet/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/dotnet"
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

sdks/java-v1/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/java"
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

sdks/java-v2/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/java"
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

sdks/node/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/javascript"
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

sdks/php/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/php"
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

sdks/python/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

sdks/ruby/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/ruby"
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)