-
Notifications
You must be signed in to change notification settings - Fork 2
51 lines (48 loc) · 1.67 KB
/
snapshot.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
name: Create Fedora CoreOS snapshot
on:
workflow_dispatch:
inputs:
url:
description: 'Fedora CoreOS image URL for Digital Ocean'
required: true
type: string
concurrency:
group: create-snapshot
cancel-in-progress: true
jobs:
snapshot:
name: Create CoreOS snapshot
runs-on: ubuntu-latest
steps:
- name: Set up doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_API_TOKEN }}
- name: Get snapshot ID
id: get_snapshot
run: |
url="${{ inputs.url }}"
snapshot_name="${url##*/}"
snapshot_id=$(doctl compute snapshot list --format ID,Name --no-header | grep " $snapshot_name\$" | awk '{print $1}')
echo "snapshot_id=$snapshot_id" >> $GITHUB_OUTPUT
- name: Check if Snapshot Exists
id: check_snapshot
run: |
snapshot_id="${{ steps.get_snapshot.outputs.snapshot_id }}"
if doctl compute snapshot get $snapshot_id > /dev/null 2>&1; then
echo "snapshot_exists=true" >> $GITHUB_OUTPUT
else
echo "snapshot_exists=false" >> $GITHUB_OUTPUT
fi
- name: Create Snapshot
if: ${{ steps.check_snapshot.outputs.snapshot_exists == 'false' }}
run: |
url="${{ inputs.url }}"
snapshot_name="${url##*/}"
doctl compute image create "${snapshot_name}" \
--verbose \
--region TOR1 \
--image-distribution "Fedora" \
--image-description "Base image for Islandora Sandbox. Does not include docker images." \
--tag-names coreos \
--image-url "${url}"