Create Fedora CoreOS snapshot #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |