From 77e7e13f05c5dac6f5bd91ae48dfaa0b4d987930 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Wed, 1 Jan 2025 16:17:05 -0600 Subject: [PATCH] move tasks to mise --- {.taskfiles/_scripts => mise-tasks}/build_import.sh | 5 +++-- {.taskfiles/_scripts => mise-tasks}/launch.sh | 3 ++- {.taskfiles/_scripts => mise-tasks}/push_token.sh | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) rename {.taskfiles/_scripts => mise-tasks}/build_import.sh (70%) rename {.taskfiles/_scripts => mise-tasks}/launch.sh (71%) rename {.taskfiles/_scripts => mise-tasks}/push_token.sh (87%) diff --git a/.taskfiles/_scripts/build_import.sh b/mise-tasks/build_import.sh similarity index 70% rename from .taskfiles/_scripts/build_import.sh rename to mise-tasks/build_import.sh index 53e0211..a181c34 100755 --- a/.taskfiles/_scripts/build_import.sh +++ b/mise-tasks/build_import.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +#MISE description="Build the qemu image and import it to Incus" # Function to check if a command was successful check_command() { @@ -9,11 +10,11 @@ check_command() { } # Build the qemu image and get the path -qemuImageBuildPath=$(nix build .#nixosConfigurations.fj-lxc-vm-x86_64.config.system.build.qemuImage --print-out-paths) +qemuImageBuildPath=$(nix build .#nixosConfigurations.lxc-vm-x86_64.config.system.build.qemuImage --print-out-paths) check_command "Building qemu image" # Build the metadata and get the path -metadataBuildPath=$(nix build .#nixosConfigurations.fj-lxc-vm-x86_64.config.system.build.metadata --print-out-paths) +metadataBuildPath=$(nix build .#nixosConfigurations.lxc-vm-x86_64.config.system.build.metadata --print-out-paths) check_command "Building metadata" # Set the paths for the metadata and qemu image diff --git a/.taskfiles/_scripts/launch.sh b/mise-tasks/launch.sh similarity index 71% rename from .taskfiles/_scripts/launch.sh rename to mise-tasks/launch.sh index de2468d..6028da2 100755 --- a/.taskfiles/_scripts/launch.sh +++ b/mise-tasks/launch.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +#MISE description="Launch the instance and push the forgejo repo token to it so it can check in." INCUS_PROFILE="forgejo-runner" @@ -6,7 +7,7 @@ INSTANCE_NAME=$(incus launch nixos-gen/custom/fj-lxc-vm-x86_64 -p ${INCUS_PROFIL echo "The captured instance name is: $INSTANCE_NAME" # Call the push_token.sh script with the new instance name -./push_token.sh "$INSTANCE_NAME" +"$MISE_TASK_DIR"/push_token.sh "$INSTANCE_NAME" echo "Pushing token to instance" echo "Process completed successfully" diff --git a/.taskfiles/_scripts/push_token.sh b/mise-tasks/push_token.sh similarity index 87% rename from .taskfiles/_scripts/push_token.sh rename to mise-tasks/push_token.sh index 8f12626..ce67f75 100755 --- a/.taskfiles/_scripts/push_token.sh +++ b/mise-tasks/push_token.sh @@ -15,22 +15,20 @@ fi INCUS_INSTANCE="$1" # Use the provided instance name # Set variables -OP_ITEM_NAME="forgejo-runner" # Name of the 1Password item containing the runner token -OP_VAULT_NAME="forgejo-runner" # Name of the 1Password vault TOKEN_FILE="tokenfile" # Name of the temporary file to store the token INCUS_PATH="/var/lib/gitea-runner/default/$TOKEN_FILE" # Check if OP_SESSION environment variable exists, if not, sign in if [ -z "${OP_SESSION:-}" ]; then echo "Not logged in to 1Password CLI. Attempting to sign in..." - if ! eval $(op signin); then + if ! eval "$(op signin)"; then echo "Failed to sign in to 1Password CLI. Please sign in manually using 'op signin'" >&2 exit 1 fi fi -# Retrieve the token from 1Password -TOKEN=$(op item get "$OP_ITEM_NAME" --vault "$OP_VAULT_NAME" --fields runner_token) +# Retrieve the token from 1Password using op:// format +TOKEN=$(op read "op://forgejo-runner/forgejo-runner/runner_token") if [ -z "$TOKEN" ]; then echo "Failed to retrieve token from 1Password" >&2