Skip to content

GitHub Secrets Setup for CyberOrigen CI/CD

This document describes the GitHub secrets required for the AWS ECS deployment workflows.

Required Secrets

Add these secrets in your GitHub repository under Settings > Secrets and variables > Actions.

AWS Credentials

Secret NameDescriptionHow to Obtain
AWS_ACCESS_KEY_IDAWS IAM access key IDCreate in AWS IAM Console
AWS_SECRET_ACCESS_KEYAWS IAM secret access keyCreate in AWS IAM Console

IAM Policy Requirements: The IAM user/role needs the following permissions:

  • ecr:GetAuthorizationToken
  • ecr:BatchCheckLayerAvailability
  • ecr:GetDownloadUrlForLayer
  • ecr:BatchGetImage
  • ecr:PutImage
  • ecr:InitiateLayerUpload
  • ecr:UploadLayerPart
  • ecr:CompleteLayerUpload
  • ecs:DescribeTaskDefinition
  • ecs:RegisterTaskDefinition
  • ecs:UpdateService
  • ecs:DescribeServices
  • iam:PassRole (for ECS task execution role)

Build-Time Secrets

Secret NameDescriptionHow to Obtain
STRIPE_PUBLISHABLE_KEYStripe publishable API key (starts with pk_)Stripe Dashboard > API Keys

Note: The publishable key is safe to embed in client-side code. It's different from the secret key which must never be exposed.

Optional Secrets (if using Cloudflare Pages for marketing)

Secret NameDescriptionHow to Obtain
CLOUDFLARE_API_TOKENCloudflare API token with Pages deploy permissionCloudflare Dashboard > API Tokens
CLOUDFLARE_ACCOUNT_IDYour Cloudflare account IDCloudflare Dashboard > Account Home

Environment Configuration

The workflows support multiple environments. Create GitHub Environments for:

  1. production - Main production deployment
  2. staging - Staging/preview environment (optional)

Environment-Specific Secrets

You can override secrets per environment if needed (e.g., different Stripe keys for staging).

Setting Up Secrets

Via GitHub UI

  1. Go to your repository on GitHub
  2. Click Settings > Secrets and variables > Actions
  3. Click New repository secret
  4. Enter the secret name and value
  5. Click Add secret

Via GitHub CLI

bash
# Install GitHub CLI if not already installed
# https://cli.github.com/

# Login to GitHub
gh auth login

# Set secrets
gh secret set AWS_ACCESS_KEY_ID
gh secret set AWS_SECRET_ACCESS_KEY
gh secret set STRIPE_PUBLISHABLE_KEY

Create an IAM user with this policy for GitHub Actions:

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ECRAuth",
      "Effect": "Allow",
      "Action": [
        "ecr:GetAuthorizationToken"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ECRPush",
      "Effect": "Allow",
      "Action": [
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:PutImage",
        "ecr:InitiateLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:CompleteLayerUpload"
      ],
      "Resource": [
        "arn:aws:ecr:us-east-1:*:repository/cyberorigen-*"
      ]
    },
    {
      "Sid": "ECSDeployment",
      "Effect": "Allow",
      "Action": [
        "ecs:DescribeTaskDefinition",
        "ecs:RegisterTaskDefinition",
        "ecs:UpdateService",
        "ecs:DescribeServices"
      ],
      "Resource": "*"
    },
    {
      "Sid": "PassRole",
      "Effect": "Allow",
      "Action": [
        "iam:PassRole"
      ],
      "Resource": [
        "arn:aws:iam::*:role/cyberorigen-*"
      ]
    },
    {
      "Sid": "CloudFormation",
      "Effect": "Allow",
      "Action": [
        "cloudformation:DescribeStacks"
      ],
      "Resource": "*"
    }
  ]
}

Workflow Triggers

WorkflowTriggerPath Filters
deploy-backend-aws.ymlPush to main, manualbackend/**, docker/Dockerfile.backend
deploy-worker-aws.ymlPush to main, manualbackend/**, docker/Dockerfile.worker
deploy-marketing-aws.ymlPush to main, manualsrc/**, Dockerfile, Caddyfile
deploy-app-ui-aws.ymlPush to main, manualui_cyberorigen/**
deploy-all-aws.ymlManual onlyN/A (deploys all services)

Manual Deployment

To manually trigger a deployment:

  1. Go to Actions tab in your repository
  2. Select the workflow (e.g., "Deploy All Services to AWS ECS")
  3. Click Run workflow
  4. Select environment and services to deploy
  5. Click Run workflow

Troubleshooting

Common Issues

  1. ECR Login Failed

    • Check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are correct
    • Verify IAM permissions include ecr:GetAuthorizationToken
  2. Push to ECR Failed

    • Verify ECR repository exists
    • Check IAM permissions for ECR push actions
  3. ECS Update Failed

    • Verify ECS cluster and service names match
    • Check IAM ecs:UpdateService permission
    • Ensure iam:PassRole is granted for ECS task roles
  4. Service Not Stabilizing

    • Check CloudWatch logs for container errors
    • Verify health check endpoints are responding
    • Check security group allows traffic from ALB

Security Best Practices

  1. Rotate credentials regularly - Update AWS access keys every 90 days
  2. Use least privilege - Only grant permissions needed for deployment
  3. Enable MFA - Require MFA for AWS IAM users
  4. Audit access - Review CloudTrail logs for unauthorized access
  5. Use OIDC - Consider using GitHub OIDC for keyless AWS authentication (advanced)

Agentic AI-Powered Security & Compliance