forked from Submitty/Submitty
-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (59 loc) · 2.5 KB
/
save_vm.yaml
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
name: Package Cloud VM
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
permissions:
contents: read
jobs:
vagrant-up:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install vagrant
run: brew install vagrant
- name: install virtual box 7.0.20
run: |
curl -LO https://download.virtualbox.org/virtualbox/7.0.20/VirtualBox-7.0.20-163906-OSX.dmg
hdiutil mount VirtualBox-7.0.20-163906-OSX.dmg
sudo installer -pkg /Volumes/VirtualBox/VirtualBox.pkg -target /
hdiutil unmount /Volumes/VirtualBox
- name: Get latest version
id: get-version
run: |
TAG=$(git describe --tags --abbrev=0)
if ! [[ $TAG =~ ^v[0-9]{2}\.[0-9]{2}\.[0-9]{2}$ ]]; then
echo "Invalid tag name: '$TAG'"
exit 1
fi
echo "version=${TAG:1}" >> $GITHUB_OUTPUT
- name: Vagrant Up
run: CI=1 vagrant up
- name: Validate image
run: curl --show-error --fail --include http://localhost:1511
- name: Save image
run: vagrant package --output submitty.box
- name: Publish image
run: |
vagrant cloud auth login --token ${{ secrets.VAGRANT_CLOUD_TOKEN }}
vagrant cloud publish SubmittyBot/ubuntu22-dev ${{ steps.get-version.outputs.version }}.$(date +"%y%m%d%H%M") virtualbox submitty.box --release --force
vagrant cloud auth logout
- name: Acquire Job ID
if: failure()
id: get-job-id
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id}}/attempts/${{ github.run_attempt }}/jobs)
job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .id')
echo "job_id=$job_id" >> $GITHUB_OUTPUT
- name: Send zulip message on failure
if: failure()
run: |
curl -X POST https://submitty.zulipchat.com/api/v1/messages -u ${{ secrets.ZULIP_AUTHENTICATION }} \
--data-urlencode 'type=stream' \
--data-urlencode 'to=Submitty Developer Studio' \
--data-urlencode 'topic=Vagrant Up Failures' \
--data-urlencode 'content=The Package Vagrant VM Github Action has failed, this means the VM is not saved, and requires attention. View here: https://github.com/Submitty/Submitty/actions/runs/${{ github.run_id }}/job/${{ steps.get-job-id.outputs.job_id }}'