MCPcopy Create free account
hub / github.com/PRX/Infrastructure / handler

Function handler

ci/src/parameter-store-updater/index.mjs:86–122  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

84}
85
86export const handler = async (event) => {
87 console.log(JSON.stringify(event));
88
89 const eventDetail = event.detail;
90 const info = eventDetail['additional-information'];
91
92 // Combine the build's passed-in environment variables and any explicitly
93 // exported environment variables (which may have been defined as part of the
94 // build, but not passed in when the build started).
95 const allEnvars = {};
96
97 for (const envar of info.environment['environment-variables'] || []) {
98 allEnvars[envar.name] = envar.value;
99 }
100
101 for (const envar of info['exported-environment-variables'] || []) {
102 allEnvars[envar.name] = envar.value;
103 }
104
105 // PRX_CI_PUBLISH will be true when the build is publishing some sort of
106 // deployable code artifact. Parameters only need to be updated when
107 // something has been published.
108 //
109 // Do **not** match on PRX_CI_PRERELEASE. The purpose of that flag is to skip
110 // parameter updates _even if_ artifacts have been published.
111 if (
112 allEnvars.PRX_CI_PUBLISH === 'true' &&
113 eventDetail['build-status'] === 'SUCCEEDED'
114 ) {
115 console.log(
116 'Artifacts were published for this build. Checking for parameters to update.',
117 );
118
119 await updateParameters(allEnvars, 'PRX_SPIRE_ECR_PKG_PARAMETERS');
120 await updateParameters(allEnvars, 'PRX_SPIRE_S3_PKG_PARAMETERS');
121 }
122};

Callers

nothing calls this directly

Calls 1

updateParametersFunction · 0.85

Tested by

no test coverage detected