-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.04 KB
/
gcp.yml
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
name: "Build machine image"
on:
push:
jobs:
build-image:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ github.ref_name }} # github.ref_name provides the branch or tag name
steps:
# Checkout the current repository
- name: Checkout repository
uses: actions/checkout@v3
- name: Check Disk Space Before
run: df -h
- name: Remove Directories and Check Disk Space After
run: |
sudo rm -rf /usr/share/dotnet \
&& sudo rm -rf /opt/ghc \
&& sudo rm -rf "/usr/local/share/boost" \
&& sudo rm -rf "$AGENT_TOOLSDIRECTORY" \
&& df -h
# Install Nix package manager
- name: Install nix
uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
# Cache the build on cachix
- name: Cache build on cachix
uses: cachix/cachix-action@v11
with:
name: cuda-maintainers
- name: Cache build on cachix
uses: cachix/cachix-action@v11
with:
name: tartavull
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
# Authenticate with Google Cloud
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
# Set up Google Cloud SDK
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
# Build and push the GCP image
- name: Build and push GCP image
run: >
nix build .#gcp &&
gsutil cp ./result/*.raw.tar.gz "gs://openmind-vision/${{ env.IMAGE_NAME }}.raw.tar.gz"
# Delete the existing image (if it exists) and create a new one
- name: Create compute image
run: >
gcloud compute images delete "${{ env.IMAGE_NAME }}" --quiet || true &&
gcloud compute images create "${{ env.IMAGE_NAME }}" --source-uri "gs://openmind-vision/${{ env.IMAGE_NAME }}.raw.tar.gz"