Skip to content

Commit

Permalink
ci: disable oci
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur committed Aug 24, 2024
1 parent a2a8d96 commit 01ac436
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 47 deletions.
80 changes: 40 additions & 40 deletions .github/workflows/tofu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,43 @@ jobs:
details: "[linode] apply cancelled"
webhookUrl: ${{ env.DISCORD_WEBHOOK }}

oci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bitwarden/sm-action@v2
with:
access_token: ${{ secrets.BW_ACCESS_TOKEN }}
base_url: https://vault.bitwarden.com
secrets: |
953077e4-dbec-4595-a0d7-b1d400d8adc6 > DISCORD_WEBHOOK
b7d22a8b-8185-4d62-8bf6-b1d400b87552 > PG_CONN_STR
8c29761d-9f79-44f1-97a1-b1d400b70984 > TF_VAR_private_key
fdc9cf76-3eed-4173-9e66-b1d400b74aaf > TF_VAR_fingerprint
f65d2583-7fe2-4ead-a4fa-b1d400b72191 > TF_VAR_tenancy_ocid
be76a461-2f01-49b8-a106-b1d400b735f4 > TF_VAR_user_ocid
b2b149a9-1a9c-4a45-b3c6-b1d400b48405 > TF_VAR_ssh_public_keys
- uses: opentofu/setup-opentofu@v1
- run: |
tofu -chdir=./terraform/oci init -upgrade
- run: |
tofu -chdir=./terraform/oci \
apply -auto-approve -input=false -lock=true -no-color
- uses: rjstone/discord-webhook-notify@v1
if: success()
with:
severity: info
details: "[oci] apply succesfull"
webhookUrl: ${{ env.DISCORD_WEBHOOK }}
- uses: rjstone/discord-webhook-notify@v1
if: failure()
with:
severity: error
details: "[oci] apply failed"
webhookUrl: ${{ env.DISCORD_WEBHOOK }}
- uses: rjstone/discord-webhook-notify@v1
if: cancelled()
with:
severity: warn
details: "[oci] apply cancelled"
webhookUrl: ${{ env.DISCORD_WEBHOOK }}
# oci:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: bitwarden/sm-action@v2
# with:
# access_token: ${{ secrets.BW_ACCESS_TOKEN }}
# base_url: https://vault.bitwarden.com
# secrets: |
# 953077e4-dbec-4595-a0d7-b1d400d8adc6 > DISCORD_WEBHOOK
# b7d22a8b-8185-4d62-8bf6-b1d400b87552 > PG_CONN_STR
# 8c29761d-9f79-44f1-97a1-b1d400b70984 > TF_VAR_private_key
# fdc9cf76-3eed-4173-9e66-b1d400b74aaf > TF_VAR_fingerprint
# f65d2583-7fe2-4ead-a4fa-b1d400b72191 > TF_VAR_tenancy_ocid
# be76a461-2f01-49b8-a106-b1d400b735f4 > TF_VAR_user_ocid
# b2b149a9-1a9c-4a45-b3c6-b1d400b48405 > TF_VAR_ssh_public_keys
# - uses: opentofu/setup-opentofu@v1
# - run: |
# tofu -chdir=./terraform/oci init -upgrade
# - run: |
# tofu -chdir=./terraform/oci \
# apply -auto-approve -input=false -lock=true -no-color
# - uses: rjstone/discord-webhook-notify@v1
# if: success()
# with:
# severity: info
# details: "[oci] apply succesfull"
# webhookUrl: ${{ env.DISCORD_WEBHOOK }}
# - uses: rjstone/discord-webhook-notify@v1
# if: failure()
# with:
# severity: error
# details: "[oci] apply failed"
# webhookUrl: ${{ env.DISCORD_WEBHOOK }}
# - uses: rjstone/discord-webhook-notify@v1
# if: cancelled()
# with:
# severity: warn
# details: "[oci] apply cancelled"
# webhookUrl: ${{ env.DISCORD_WEBHOOK }}
26 changes: 26 additions & 0 deletions scripts/oci-500.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

source .env

# Define your command here
command_to_run="tofu -chdir=./terraform/oci apply -auto-approve"

# Function to generate a random sleep time between 1 and 5 seconds
function jitter_backoff() {
sleep_time=$(shuf -i 1-5 -n 1)
echo "Sleeping for $sleep_time seconds before retrying..."
sleep $sleep_time
}

# Loop to run the command until it succeeds
while true; do
export TF_VAR_availability_domain=$(shuf -i 1-3 -n 1)

if $command_to_run ; then
echo "Command completed successfully."
break
else
echo "Command failed with exit code $exit_code. Retrying..."
jitter_backoff
fi
done
8 changes: 5 additions & 3 deletions terraform/oci/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module "oci_core" {

instance_name = "BdxPwD"

tenancy_ocid = var.tenancy_ocid
tenancy_ocid = var.tenancy_ocid
availability_domain = var.availability_domain
}

module "oci_a1_flex" {
Expand All @@ -20,7 +21,8 @@ module "oci_a1_flex" {
instance_name = "XUjVp3"
subnet_id = module.oci_core.subnet_id

tenancy_ocid = var.tenancy_ocid
ssh_public_keys = var.ssh_public_keys
tenancy_ocid = var.tenancy_ocid
ssh_public_keys = var.ssh_public_keys
availability_domain = var.availability_domain
}

1 change: 0 additions & 1 deletion terraform/oci/modules/a1_flex/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ variable "subnet_id" {
variable "availability_domain" {
type = number
description = "Availability Domain of the instance."
default = 3
}

variable "region" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/oci/modules/a1_flex/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
oci = {
source = "oracle/oci"
source = "oracle/oci"
}
}
}
1 change: 0 additions & 1 deletion terraform/oci/modules/core/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ variable "instance_name" {
variable "availability_domain" {
type = number
description = "Availability Domain of the instance."
default = 3
}

variable "region" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/oci/modules/core/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
oci = {
source = "oracle/oci"
source = "oracle/oci"
}
}
}
6 changes: 6 additions & 0 deletions terraform/oci/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ variable "region" {
description = "The oci region where resources will be created."
default = "eu-frankfurt-1"
}

variable "availability_domain" {
type = number
description = "Availability Domain of the instance."
default = 3
}

0 comments on commit 01ac436

Please sign in to comment.