Skip to content

Instantly share code, notes, and snippets.

@Duologic
Last active August 5, 2024 17:53
Show Gist options
  • Save Duologic/c79dafe24652455a3da7b35ea703340a to your computer and use it in GitHub Desktop.
Save Duologic/c79dafe24652455a3da7b35ea703340a to your computer and use it in GitHub Desktop.
// Run like this: `eval $(jsonnet -S <this file>)`
//
// versions.libsonnet has entries like this:
// {
// cacheRestore: {
// version: 'v4.0.2',
// sha: '0c45773b623bea8c8e75f6c82b208c3cf94ea4f9',
// action: 'actions/cache/restore',
// },
// ...
// }
local versions = import 'versions.libsonnet';
local sed(file, needle, replacement) =
"sed -i 's;" + needle + ';' + replacement + ";' " + file;
local commands(file) = [
sed(
file,
'uses: ' + versions[v].action + '@.*',
'uses: ' + versions[v].action + '@' + versions[v].sha + ' # ' + versions[v].version,
)
for v in std.objectFields(versions)
if 'version' in versions[v]
];
std.join(
';',
commands('../workflows/workflow1.yaml')
+ commands('../workflows/workflow2.yaml')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment