forked from lloorree/maze-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (81 loc) · 3.61 KB
/
Copy pathdeploy.yml
File metadata and controls
91 lines (81 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Deploy Built Extension
on:
push:
branches:
- main # Or any branch you use for releases
- master
permissions:
contents: write
issues: read
jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '21.7.1'
- name: Confirm CHUB_AUTH_TOKEN is set
env:
CHUB_AUTH_TOKEN: ${{ secrets.CHUB_AUTH_TOKEN }}
run: |
if [ "${{ secrets.CHUB_AUTH_TOKEN }}" == "" ] || [ "${{ secrets.CHUB_AUTH_TOKEN }}" == "null" ]; then
echo "Your CHUB_AUTH_TOKEN secret is not set for this project. Cannot proceed."
exit 1
fi
- name: Get or Make Extension ID
env:
CHUB_AUTH_TOKEN: ${{ secrets.CHUB_AUTH_TOKEN }}
EXTENSION_ID: ${{ secrets.EXTENSION_ID }}
run: |
mkdir -p public/
touch public/chub_meta.yaml
if grep -q "github_path:" public/chub_meta.yaml; then
echo "Repo path already in metadata file."
else
echo "Writing github path 'https://github.com/${{ github.repository }}' to metadata file."
echo "github_path: 'https://github.com/${{ github.repository }}'" >> public/chub_meta.yaml
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add public/chub_meta.yaml
git commit -m "Add github_path to chub_meta.yaml" || true
git push
fi
if [ "${{ secrets.EXTENSION_ID }}" == "" ]; then
echo "Secret EXTENSION_ID does not exist; attempting to read from file"
EXTENSION_ID=$(grep '^extension_id:' public/chub_meta.yaml | cut -d ':' -f2 | tr -d " '\"")
if [ "${EXTENSION_ID}" == "" ]; then
echo "Extension ID not present in public/chub_meta.yaml extension_id field either. Creating new project."
sudo apt-get install jq
EXTENSION_ID=""
curl -H "CH-API-KEY: ${{ secrets.CHUB_AUTH_TOKEN }}" -H "Content-Type: application/json" --request POST --data '{"name":"${{ github.event.repository.name }}"}' https://api.chub.ai/extensions -o creation.json
EXTENSION_ID=$(jq -r '.id_v2' creation.json)
if [ "${EXTENSION_ID}" == "" ] || [ "${EXTENSION_ID}" == "null" ]; then
echo "Extension ID creation failed; is your CHUB_AUTH_TOKEN secret set for this project?"
exit 1
fi
echo "extension_id: '${EXTENSION_ID}'" >> public/chub_meta.yaml
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add public/chub_meta.yaml
git commit -m "Add new Extension ID to chub_meta.yaml" || true
git push
else
echo "Extension ID found in public/chub_meta.yaml."
fi
else
EXTENSION_ID=${{ secrets.EXTENSION_ID }}
fi
echo "EXTENSION_ID=${EXTENSION_ID}" >> $GITHUB_ENV
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Zip the build folder
run: cd dist && zip -r ../build.zip * && cd ../
- name: Upload the build
env:
CHUB_AUTH_TOKEN: ${{ secrets.CHUB_AUTH_TOKEN }}
run: |
curl -H "CH-API-KEY: ${{ secrets.CHUB_AUTH_TOKEN }}" -F "file=@build.zip" https://api.chub.ai/extension/${{ env.EXTENSION_ID }}/upload