-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
4,726 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# <!--name-->snapshoty/run<!--/name--> | ||
|
||
|
||
<!--description--> | ||
The best way to handle snapshot lifecycle. | ||
<!--/description--> | ||
|
||
## Inputs | ||
<!--inputs--> | ||
| Name | Description | Required | Default | | ||
|----------------------|----------------------------------------------------|----------|---------| | ||
| `config` | Path to configuration file | `true` | ` ` | | ||
| `bucket-name` | Name of the bucket to use | `true` | ` ` | | ||
| `gcs-client-email` | Google Cloud email of the service account | `true` | ` ` | | ||
| `gcs-private-key` | Google Cloud private key of the service account | `true` | ` ` | | ||
| `gcs-private-key-id` | Google Cloud private key id of the service account | `true` | ` ` | | ||
| `gcs-project` | Google Cloud project id of the service account | `true` | ` ` | | ||
<!--/inputs--> | ||
|
||
In addition, you can pass env variables with the prefix `SNAPSHOTY_`, the prefix will be removed and the name | ||
of the variable will be passed. | ||
|
||
## Usage | ||
|
||
<!--usage action="elastic/oblt-actions/snapshoty/run" version="env:VERSION"--> | ||
```yaml | ||
steps: | ||
- uses: elastic/oblt-actions/snapshoty/run@v1 | ||
with: | ||
config: snapshoty.yml | ||
bucket-name: 'my-bucket' | ||
gcs-client-email: '[email protected]' | ||
gcs-private-ley: 'my-secret-key' | ||
gcs-private-key-id: 'my-private-key' | ||
gcs-project: 'my-gcs-project' | ||
env: | ||
SNAPSHOTY_DATE: "2023-09-20" | ||
``` | ||
<!--/usage--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'snapshoty/run' | ||
description: 'The best way to handle snapshot lifecycle.' | ||
inputs: | ||
config: | ||
description: 'Path to configuration file' | ||
required: true | ||
bucket-name: | ||
description: 'Name of the bucket to use' | ||
required: true | ||
gcs-client-email: | ||
description: 'Google Cloud email of the service account' | ||
required: true | ||
gcs-private-key: | ||
description: 'Google Cloud private key of the service account' | ||
required: true | ||
gcs-private-key-id: | ||
description: 'Google Cloud private key id of the service account' | ||
required: true | ||
gcs-project: | ||
description: 'Google Cloud project id of the service account' | ||
required: true | ||
runs: | ||
using: 'node20' | ||
main: 'dist/index.js' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
@actions/core | ||
MIT | ||
The MIT License (MIT) | ||
|
||
Copyright 2019 GitHub | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
@actions/exec | ||
MIT | ||
The MIT License (MIT) | ||
|
||
Copyright 2019 GitHub | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
@actions/http-client | ||
MIT | ||
Actions Http Client for Node.js | ||
|
||
Copyright (c) GitHub, Inc. | ||
|
||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
associated documentation files (the "Software"), to deal in the Software without restriction, | ||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
@actions/io | ||
MIT | ||
The MIT License (MIT) | ||
|
||
Copyright 2019 GitHub | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
@fastify/busboy | ||
MIT | ||
Copyright Brian White. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
|
||
tunnel | ||
MIT | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2012 Koichi Kobayashi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
|
||
undici | ||
MIT | ||
MIT License | ||
|
||
Copyright (c) Matteo Collina and Undici contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
||
uuid | ||
MIT | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2010-2020 Robert Kieffer and other contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const core = require('@actions/core'); | ||
const exec = require('@actions/exec'); | ||
const os = require("os"); | ||
|
||
async function run() { | ||
try { | ||
const gcsClientEmail = core.getInput('gcs-client-email'); | ||
const gcsPrivateKey = core.getInput('gcs-private-key'); | ||
const gcsPrivateKeyId = core.getInput('gcs-private-key-id'); | ||
const gcsProject = core.getInput('gcs-project'); | ||
const bucketName = core.getInput('bucket-name'); | ||
const config = core.getInput('config'); | ||
|
||
const workDir = process.env.GITHUB_WORKSPACE; | ||
const userInfo = os.userInfo(); | ||
|
||
const args = [ | ||
'run', '--rm', | ||
'-v', `${workDir}:/app`, | ||
'-u', `${userInfo.uid}:${userInfo.gid}`, | ||
'-w', '/app', | ||
'-e', `GCS_CLIENT_EMAIL=${gcsClientEmail}`, | ||
'-e', `GCS_PRIVATE_KEY=${gcsPrivateKey}`, | ||
'-e', `GCS_PRIVATE_KEY_ID=${gcsPrivateKeyId}`, | ||
'-e', `GCS_PROJECT=${gcsProject}` | ||
] | ||
|
||
// GCS env vars are secrets | ||
for (secret of [gcsClientEmail, gcsPrivateKey, gcsPrivateKeyId, gcsProject]) { | ||
core.setSecret(secret); | ||
} | ||
|
||
// Forward env vars | ||
Object.keys(process.env).forEach(function (key) { | ||
if (key.startsWith("GITHUB_") || key.startsWith("RUNNER_")) { | ||
let value = process.env[key]; | ||
args.push('-e', `${key}=${value}`); | ||
|
||
if (key === 'GITHUB_TOKEN') { | ||
core.setSecret(value); | ||
} | ||
} | ||
|
||
// Special case so we can inject env variables | ||
if (key.startsWith("SNAPSHOTY_")) { | ||
let value = process.env[key]; | ||
let variable = key.replace("SNAPSHOTY_", "") | ||
args.push('-e', `${variable}=${value}`); | ||
} | ||
}); | ||
args.push('docker.elastic.co/observability-ci/snapshoty:v1', 'snapshoty'); | ||
if (core.isDebug()) { | ||
args.push('--debug'); | ||
} | ||
args.push('--config', config, 'upload', '--bucket-name', bucketName); | ||
|
||
return await exec.exec('docker', args); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
Oops, something went wrong.