Skip to main content

GitHub Workflows

This repository uses three automated workflows for CI/CD and content management.


1. Continuous Deployment (cd.yml)

Trigger: Push to main branch

Purpose: Build and deploy the application to production

Steps:

  1. Build Docker Image

    • Uses environment variables from GitHub Secrets/Variables
    • Passes build args: OPENAI_API_KEY, NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY
    • Pushes to Docker registry: registry.abair.ie:5000
  2. Deploy to Server

    • SSH into production server
    • Executes deployment script to pull and restart container

Required Configuration:

TypeNamePurpose
SecretDOCKER_REGISTRYDocker registry URL
SecretDOCKER_USERNAMEDocker registry username
SecretDOCKER_PASSWORDDocker registry password
SecretOPENAI_API_KEYOpenAI API key for GPT-4o
SecretHOSTProduction server hostname
SecretUSERNAMESSH username
SecretKEYSSH private key
SecretPORTSSH port
SecretDEPLOY_SCRIPT_PATHPath to deployment script on server
VariableNEXT_PUBLIC_SUPABASE_URLSupabase project URL
VariableNEXT_PUBLIC_SUPABASE_ANON_KEYSupabase anonymous key
VariablePROJECT_NAMEDocker image name

2. Continuous Integration (ci.yml)

Trigger: Pull requests to main branch

Purpose: Verify builds succeed before merging

Steps:

  1. Checkout code
  2. Setup Node.js 18.16.0
  3. Install dependencies (npm i)

Note: Currently only validates dependency installation. No build/test steps configured.


3. Update Translations (update_translations.yml)

Trigger: Repository dispatch event with type update-translations

Purpose: Allow programmatic updates to translation files from external systems

Steps:

  1. Verify Requester

    • Checks if the requesting user is a repository collaborator
    • Aborts if user lacks permissions
  2. Update Translation File

    • Receives file path and content via event payload
    • Creates/updates JSON translation file
  3. Commit & Push

    • Commits changes directly to main branch
    • Uses requester's username for git author

Event Payload Requirements:

{
"username": "github-username",
"file_path": "locales/resources.json",
"content": "{ ... JSON content ... }",
"commit_message": "Update translations"
}

Use Case: Integration with translation management systems or automated localization tools.


Workflow Execution

  • cd.yml: Runs automatically on every push to main
  • ci.yml: Runs automatically on all PRs targeting main
  • update_translations.yml: Triggered manually via API:
    curl -X POST \
    -H "Authorization: token $GITHUB_TOKEN" \
    -H "Accept: application/vnd.github.v3+json" \
    https://api.github.com/repos/OWNER/REPO/dispatches \
    -d '{"event_type":"update-translations","client_payload":{...}}'