Skip to content

Commit c608955

Browse files
committed
ci: use snapshot deploy secret directly
Instead of encoding the GitHub snapshot robot access token in a file that needs to be decoded by an ambiguously named secret called `KEY`, the token can be directly stored in the secrets of CircleCI given easier maintenance and the same risk. The leakage of the secret still means the GitHub token file could be decoded. We are switching to a similar model as in the components repo, which also simplifies key rotations etc.
1 parent 7f93735 commit c608955

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

.circleci/dynamic_config.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,9 @@ jobs:
317317
steps:
318318
- custom_attach_workspace
319319
- install_python
320-
- run:
321-
name: Decrypt Credentials
322-
# Note: when changing the image, you might have to re-encrypt the credentials with a
323-
# matching version of openssl.
324-
# See https://stackoverflow.com/a/43847627/2116927 for more info.
325-
command: |
326-
openssl aes-256-cbc -d -in .circleci/github_token -k "${KEY}" -out ~/github_token -md md5
327320
- run:
328321
name: Deployment to Snapshot
329-
command: |
330-
yarn admin snapshots --verbose --githubTokenFile=${HOME}/github_token
322+
command: yarn admin snapshots --verbose
331323
- fail_fast
332324

333325
publish_artifacts:

.circleci/github_token

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/snapshots.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ async function _publishSnapshot(
130130

131131
export interface SnapshotsOptions {
132132
force?: boolean;
133-
githubTokenFile?: string;
134133
githubToken?: string;
135134
branch?: string;
136135
}
@@ -151,11 +150,7 @@ export default async function (opts: SnapshotsOptions, logger: logging.Logger) {
151150
branch = '' + process.env['CIRCLE_BRANCH'];
152151
}
153152

154-
const githubToken = (
155-
opts.githubToken ||
156-
(opts.githubTokenFile && fs.readFileSync(opts.githubTokenFile, 'utf-8')) ||
157-
''
158-
).trim();
153+
const githubToken = (opts.githubToken || process.env.SNAPSHOT_BUILDS_GITHUB_TOKEN || '').trim();
159154

160155
if (githubToken) {
161156
logger.info('Setting up global git name.');

0 commit comments

Comments
 (0)