on master help sign in
ops: deploy actions
commit93d6ad89d18c3e9019d62744991dc361ffb78b06 authorHunter Miller <hunter@hmiller.dev> dateSat 29 Apr 2023, 21:01 (3 years ago) parent70630c8
3 files changed+144
.github/actions/glob/action.yml+29 .github/helpers/glob.sh+35 .github/workflows/deploy.yml+80
.github/actions/glob/action.ymlnew file+29
@@ -0,0 +1,29 @@
1+name: 'glob'
2+description: 'Create a glob and push to develop'
3+inputs:
4+ folder:
5+ description: "Folder to glob"
6+ required: true
7+ docket:
8+ description: "Docket file to edit"
9+ required: true
10+outputs:
11+ hash:
12+ description: "Glob hash"
13+ value: ${{ steps.glob.outputs.hash }}
14+runs:
15+ using: "composite"
16+ steps:
17+ - name: Set up S3cmd cli tool
18+ uses: s3-actions/s3cmd@v1.4.0
19+ with:
20+ provider: aws
21+ region: 'us-east-1'
22+ access_key: ${{ secrets.S3_ACCESS_KEY }}
23+ secret_key: ${{ secrets.S3_SECRET_KEY }}
24+ host_base: nyc3.digitaloceanspaces.com
25+ host_bucket: '%(bucket)s.nyc3.digitaloceanspaces.com'
26+ - id: glob
27+ shell: bash
28+ run:
29+ ./.github/helpers/glob.sh "${{ inputs.folder }}" ${{ inputs.docket }}
.github/helpers/glob.shnew file+35
@@ -0,0 +1,35 @@
1+#!/usr/bin/env bash
2+
3+# this script globs a folder of files, then subsequently uploads the
4+# glob to bootstrap.urbit.org and replaces the hash in the docket file.
5+# assumes gcloud credentials are loaded and gsutil installed.
6+
7+# $1: the folder of files to glob
8+# $2: the location of the docket file
9+
10+# globber is a prebooted and docked fakezod
11+curl https://bootstrap.urbit.org/globberv3.tgz | tar xzk
12+./zod/.run -d
13+
14+dojo () {
15+ curl -s --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' http://localhost:12321
16+}
17+
18+hood () {
19+ curl -s --data '{"source":{"dojo":"+hood/'"$1"'"},"sink":{"app":"hood"}}' http://localhost:12321
20+}
21+
22+rsync -avL $1 zod/work/glob
23+hood "commit %work"
24+dojo "-garden!make-glob %work /glob"
25+
26+s3cmd put zod/.urb/put/*.glob -P s3://hmillerdev/sphinx/
27+gsutil cp zod/.urb/put/*.glob gs://bootstrap.urbit.org
28+hash=$(ls -1 -c zod/.urb/put | head -1 | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
29+sed -i "s/glob\-[a-z0-9\.]*glob' *[a-z0-9\.]*\]/glob-$hash.glob' $hash]/g" $2
30+
31+echo "hash=$(echo $hash)" >> $GITHUB_OUTPUT
32+
33+hood "exit"
34+sleep 5s
35+rm -rf zod
.github/workflows/deploy.ymlnew file+80
@@ -0,0 +1,80 @@
1+name: Deploy Sphinx
2+on:
3+ workflow_dispatch:
4+ inputs:
5+ tag:
6+ type: string
7+ required: false
8+ default: master
9+ description: Enter the tag to deploy
10+ push:
11+ branches:
12+ - 'master'
13+jobs:
14+ build-frontend:
15+ runs-on: ubuntu-latest
16+ name: 'Build Frontend'
17+ steps:
18+ - uses: actions/checkout@v3
19+ with:
20+ ref: ${{ github.event.inputs.tag }}
21+ - uses: actions/setup-node@v3
22+ with:
23+ node-version-file: ./ui/.nvmrc
24+ - working-directory: ./ui
25+ run: |
26+ npm ci
27+ npm run build
28+ - uses: actions/upload-artifact@v3
29+ with:
30+ name: 'ui-dist'
31+ path: ui/dist
32+ glob:
33+ runs-on: ubuntu-latest
34+ name: 'Make a glob'
35+ needs: build-frontend
36+ steps:
37+ - uses: actions/checkout@v3
38+ with:
39+ ref: ${{ github.event.inputs.tag }}
40+ - uses: actions/download-artifact@v3
41+ with:
42+ name: 'ui-dist'
43+ path: ui/dist
44+ - name: 'glob'
45+ uses: ./.github/actions/glob
46+ with:
47+ folder: 'ui/dist/*'
48+ docket: 'desk/desk.docket-0'
49+ - name: Commit and Push Glob
50+ run: |
51+ git config --global user.name github-actions
52+ git config --global user.email github-actions@github.com
53+ git add desk/desk.docket-0
54+ git commit -n -m "update glob: ${{ steps.glob.outputs.hash }} [skip actions]" || echo "No changes to commit"
55+ INPUT=${{ github.event.inputs.tag }}
56+ BRANCH=${INPUT:-"master"}
57+ git pull origin $BRANCH --rebase --autostash
58+ git push
59+ # deploy:
60+ # runs-on: ubuntu-latest
61+ # needs: glob
62+ # name: "Deploy sphinx to live"
63+ # steps:
64+ # - uses: actions/checkout@v3
65+ # with:
66+ # ref: ${{ github.event.inputs.tag }}
67+ # - id: 'auth'
68+ # uses: 'google-github-actions/auth@v1'
69+ # with:
70+ # credentials_json: '${{ secrets.JANEWAY_SERVICE_KEY }}'
71+ # - name: 'Set up Cloud SDK'
72+ # uses: 'google-github-actions/setup-gcloud@v1'
73+ # - id: deploy
74+ # name: Deploy
75+ # run:
76+ # ./.github/helpers/deploy.sh tloncorp/landscape-apps groups wannec-dozzod-marzod us-west1-b ${{ github.event.inputs.tag }}
77+ # env:
78+ # SSH_SEC_KEY: ${{ secrets.JANEWAY_SSH_SEC_KEY }}
79+ # SSH_PUB_KEY: ${{ secrets.JANEWAY_SSH_PUB_KEY }}
80+ # URBIT_REPO_TAG: ${{ vars.URBIT_REPO_TAG }}