meta: add a 'glob' GitHub action

This action, when supplied with the appropriate arguments, will create a
Landscape glob from GITHUB_SHA [1] and deploy it OTA to the appropriate
ship.

It needs to be supplied the following:

* ship name
* base64-encoded GCP Service Account credentials
* a base64-encoded SSH secret key to be used for GCP actions
* the corresponding base64-encoded SSH public key

[1]: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables
This commit is contained in:
Jared Tobin 2020-12-19 10:22:14 -03:30
parent 598a46d1f7
commit 7b1b4d8cc6
No known key found for this signature in database
GPG Key ID: B77DC7C964AAD99A
3 changed files with 62 additions and 0 deletions

5
.github/actions/glob/Dockerfile vendored Normal file
View File

@ -0,0 +1,5 @@
FROM jaredtobin/janeway:v0.13.1
COPY entrypoint.sh /entrypoint.sh
USER 0:0
EXPOSE 22/tcp
ENTRYPOINT ["/entrypoint.sh"]

25
.github/actions/glob/action.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: 'glob'
description: 'Create a glob and deploy it to a moon'
inputs:
- ship:
description: "Ship to deploy to"
required: true
- credentials:
description: "base64-encoded GCP Service Account credentials"
required: true
- ssh-sec-key:
description: "A base64-encoded SSH secret key for the container to use"
required: true
- ssh-pub-key:
description: "The corresponding base64-encoded SSH public key"
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.ship }}
- ${{ inputs.credentials }}
- ${{ inputs.ssh-sec-key }}
- ${{ inputs.ssh-pub-key }}

32
.github/actions/glob/entrypoint.sh vendored Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
cd "$GITHUB_WORKSPACE" || exit
echo "$2" | base64 -d > service-account
echo "$3" | base64 -d > id_ssh
echo "$4" | base64 -d > id_ssh.pub
chmod 600 service-account
chmod 600 id_ssh
chmod 600 id_ssh.pub
janeway release glob --no-pill \
--credentials service-account \
--ssh-key id_ssh \
--do-it-live \
| bash
SHORTHASH=$(git rev-parse --short HEAD)
janeway release prepare-ota arvo-glob-"$SHORTHASH" "$1" \
--credentials service-account \
--ssh-key id_ssh \
--do-it-live \
| bash
janeway release perform-ota "$1" \
--credentials service-account \
--ssh-key id_ssh \
--do-it-live \
| bash