From 9e58f6a0cbdd1d7873c5ef9d6134bcc5c4718c91 Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Tue, 31 Jan 2023 12:36:54 -0600 Subject: [PATCH] ops: converting deploy action to bash script --- .github/actions/release/Dockerfile | 4 --- .github/actions/release/action.yml | 32 ------------------------ .github/actions/release/entrypoint.sh | 19 -------------- .github/helpers/deploy.sh | 36 +++++++++++++++++++++++++++ .github/workflows/deploy.yml | 10 +++----- 5 files changed, 39 insertions(+), 62 deletions(-) delete mode 100644 .github/actions/release/Dockerfile delete mode 100644 .github/actions/release/action.yml delete mode 100755 .github/actions/release/entrypoint.sh create mode 100644 .github/helpers/deploy.sh diff --git a/.github/actions/release/Dockerfile b/.github/actions/release/Dockerfile deleted file mode 100644 index 95520b5..0000000 --- a/.github/actions/release/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM tloncorp/janeway:v0.16.8-dev -COPY entrypoint.sh /entrypoint.sh -EXPOSE 22/tcp -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml deleted file mode 100644 index 8a63dba..0000000 --- a/.github/actions/release/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: 'release' -description: 'Release to a moon' -inputs: - app: - description: "App to deploy" - required: true - 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 - ref: - description: "The github reference to checkout when deploying" - required: false - -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.app }} - - ${{ inputs.ship }} - - ${{ inputs.credentials }} - - ${{ inputs.ssh-sec-key }} - - ${{ inputs.ssh-pub-key }} - - ${{ inputs.ref }} diff --git a/.github/actions/release/entrypoint.sh b/.github/actions/release/entrypoint.sh deleted file mode 100755 index 1a13c42..0000000 --- a/.github/actions/release/entrypoint.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -echo "$3" | base64 -d > /service-account -echo "$4" | base64 -d > /id_ssh -echo "$5" | base64 -d > /id_ssh.pub - -chmod 600 /service-account -chmod 600 /id_ssh -chmod 600 /id_ssh.pub - -janeway \ - --ci \ - --verbose \ - --credentials /service-account \ - --ssh-key /id_ssh \ - release ota \ - "$1" "$2" \ - ${6:+"--ref"} ${6:+"$6"} \ - | bash diff --git a/.github/helpers/deploy.sh b/.github/helpers/deploy.sh new file mode 100644 index 0000000..2928154 --- /dev/null +++ b/.github/helpers/deploy.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# this script deploys a desk to a ship from a github repository +# assumes gcloud credentials are loaded and gcloud installed. + +repo=$1 +desk=$2 +ship=$3 +zone=$4 +folder=$ship/$desk + +set -e +set -o pipefail +cmds=$(mktemp "${TMPDIR:-/tmp/}janeway.XXXXXXXXX") +echo ' +source_repo=$(mktemp --dry-run /tmp/repo.janeway.XXXXXXXXX) +git clone git@github.com:'$repo'.git $source_repo +urbit_repo=$(mktemp --dry-run /tmp/repo.urbit.XXXXXXXXX) +git clone git@github.com:urbit/urbit.git $urbit_repo +cd $source_repo +git checkout . +cd /home/urb || return +curl -s --data '"'"'{"source":{"dojo":"+hood/mount %'$desk'"},"sink":{"app":"hood"}}'"'"' http://localhost:12321 +rsync -avL --delete $source_repo/desk/ '$folder' +rsync -avL $urbit_repo/pkg/base-dev/ '$folder' +curl -s --data '"'"'{"source":{"dojo":"+hood/commit %'$desk'"},"sink":{"app":"hood"}}'"'"' http://localhost:12321 +rm -rf $source_repo +rm -rf $urbit_repo +' >> "$cmds" +gcloud compute \ + --project mainnet \ + ssh \ + --ssh-flag="-T" \ + --zone $4 \ + urb@$ship < "$cmds" &> /dev/null +echo "OTA performed for $desk on $ship" \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d01f3e1..d88e381 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,10 +36,6 @@ jobs: with: add: '-A' message: 'update glob: ${{ steps.glob.outputs.hash }} [skip actions]' - - uses: ./.github/actions/release - with: - app: 'landscape' - ship: 'devstream' - credentials: ${{ secrets.JANEWAY_SERVICE_KEY }} - ssh-sec-key: ${{ secrets.JANEWAY_SSH_SEC_KEY }} - ssh-pub-key: ${{ secrets.JANEWAY_SSH_PUB_KEY }} \ No newline at end of file + - id: deploy + run: + ./.github/helpers/deploy.sh tloncorp/landscape landscape wannec-dozzod-marzod us-west1-b \ No newline at end of file