Skip to content

Commit

Permalink
add module release process
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Apr 1, 2025
1 parent a6533bf commit 051cc26
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 6 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/terraform-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Terraform CI/CD
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
jobs:
terraform-ci-cd:
runs-on: 229685449397
permissions:
contents: write

steps:
- name: Checkout code
uses: CSVD/gh-actions-checkout@v4

- name: Setup Terraform
uses: CSVD/gh-actions-setup-terraform@v3
with:
terraform_version: "1.9.1"

- name: Setup GITHUB Credentials
id: github_credentials
uses: CSVD/gh-auth@main
with:
github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }}
github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }}
github_app_id: ${{ vars.GH_APP_ID }}


- name: Debug Authentication
run: |
# Print the GitHub server URL
echo "GitHub Server URL: ${{ github.server_url }}"
# Extract the host from the URL
HOST="${{ github.server_url }}"
HOST="${HOST#*//}"
HOST="${HOST%%/*}"
echo "GitHub Host: $HOST"
# Check if token exists
if [[ -n "${{ steps.github_credentials.outputs.github_token }}" ]]; then
echo "Token generated successfully"
# Test the token with a simple GitHub API call (without exposing the token)
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ steps.github_credentials.outputs.github_token }}" "${{ github.server_url }}/api/v3/user")
echo "API Test Status Code: $STATUS"
else
echo "No token was generated!"
fi
- name: Setup GitHub CLI
run: |
# Force manual authentication since setup-git might not work with GitHub Enterprise
echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt
gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt
rm /tmp/token.txt
# Test GitHub CLI auth status
gh auth status || echo "GitHub CLI authentication failed"
- name: AWS Auth
id: aws_auth
uses: CSVD/aws-auth@main
with:
ecs: true

- name: Run Terraform Module Release Action
uses: CSVD/terraform-module-release@main
with:
github-token: ${{ steps.github_credentials.outputs.github_token }}
working-directory: '.'
43 changes: 43 additions & 0 deletions .github/workflows/terraform-validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Terraform Validate
on:
pull_request:
workflow_dispatch:

jobs:

terraform-validate:
runs-on: "229685449397"
permissions:
contents: write
steps:
- name: Checkout code
uses: CSVD/gh-actions-checkout@v4

- name: Setup Terraform
uses: CSVD/gh-actions-setup-terraform@v2
with:
terraform_version: '1.7.3'

- name: Validate Terraform Configuration
id: validate
uses: CSVD/terraform-validate@main

- name: Check Validation/Test Results
if: always()
run: |
# Set default values if outputs are empty
IS_VALID="${{ steps.validate.outputs.is_valid }}"
TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}"
# If outputs are empty, set them to false
[ -z "$IS_VALID" ] && IS_VALID="false"
[ -z "$TESTS_PASSED" ] && TESTS_PASSED="false"
if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then
echo "Validation or test errors found:"
echo "${{ steps.validate.outputs.stderr }}"
exit 1
else
echo "All validations and tests passed successfully!"
fi
10 changes: 4 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
locals {
telemetry_ns = var.namespace

otel_internal_hostname = format("otel-daemonset-collector.%v.svc.cluster.local", local.telemetry_ns)
otel_internal_hostname = format("otel-daemonset-collector.%v.svc.cluster.local", var.namespace)
otel_internal_port_number = 4318
otel_internal_url = format("http://%v:%v/", local.otel_internal_hostname, local.otel_internal_port_number)
}
Expand All @@ -14,7 +12,7 @@ resource "helm_release" "opentelemetry-operator" {

chart = "opentelemetry-operator"
name = "opentelemetry-operator"
namespace = local.telemetry_ns
namespace = var.namespace
repository = var.otel_helm_repo
version = var.otel_helm_version

Expand Down Expand Up @@ -78,7 +76,7 @@ resource "helm_release" "otel-resources" {

chart = "./otel"
name = "otel-resources"
namespace = local.telemetry_ns
namespace = var.namespace
version = local.module_version

set {
Expand Down Expand Up @@ -126,4 +124,4 @@ resource "helm_release" "otel-resources" {
name = "autoinstrumentation.java.tag"
value = module.images.images[local.auto_instrumentation_java_key].tag
}
}
}

0 comments on commit 051cc26

Please sign in to comment.