Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GitHub Actions for SST Deployment with Linkarooie API Integration #161

Open
loftwah opened this issue Sep 17, 2024 · 0 comments
Open

Comments

@loftwah
Copy link
Owner

loftwah commented Sep 17, 2024

We need to create GitHub Actions workflows that will automate our deployments using SST (Serverless Stack Toolkit) and interact with the Linkarooie API. This will streamline our development process, enable continuous integration and deployment, and allow for automated resource management.

Prerequisites:

Tasks:

  1. Set up basic SST GitHub Actions workflow:

    • Create a workflow for building and deploying the SST application
    • Include steps for installing dependencies, building, and deploying to different stages (dev, staging, prod)
  2. Implement API authentication in GitHub Actions:

    • Set up secrets in the GitHub repository for storing API credentials
    • Create a step to authenticate with the Linkarooie API using these credentials
  3. Update SST configuration:

    • Ensure the SST config file (sst.config.ts) is properly set up with our services, including the API and any databases
  4. Create custom GitHub Actions for Linkarooie API interactions:

    • Action for creating/updating users
    • Action for managing links
    • Action for managing achievements
  5. Implement workflow for automated testing:

    • Set up a workflow to run unit and integration tests
    • Include API interaction tests using the custom actions
  6. Create deployment workflow:

    • Implement a workflow for deploying to different stages (dev, staging, prod)
    • Include steps for updating related Linkarooie resources via the API post-deployment
  7. Implement rollback mechanism:

    • Create a workflow that can rollback deployments if issues are detected
    • Include steps to revert any API changes made during deployment
  8. Set up monitoring and alerting:

    • Implement a workflow that periodically checks the health of the deployed SST stacks
    • Set up alerts using the GitHub Actions notifications
  9. Implement caching:

    • Set up caching for dependencies and build artifacts to speed up workflows
  10. Create documentation:

    • Write detailed documentation on how to use and extend these GitHub Actions
    • Include examples of workflow files and how to configure them
  11. Implement branch protections:

    • Set up branch protection rules that require status checks to pass before merging

Example SST configuration file:

import { SSTConfig } from 'sst';
import { API } from './stacks/ApiStack';
import { Web } from './stacks/WebStack';
import { Database } from './stacks/DatabaseStack';

export default {
  config(_input) {
    return {
      name: 'linkarooie',
      region: 'us-east-1',
    };
  },
  stacks(app) {
    app.stack(Database)
       .stack(API)
       .stack(Web);
  }
} satisfies SSTConfig;

Example workflow file structure:

name: SST Deploy and Linkarooie API Update

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '16'
      - run: npm ci
      - run: npm test

  deploy:
    needs: build-and-test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '16'
      - run: npm ci
      - name: Deploy with SST
        run: npx sst deploy --stage ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

  update-linkarooie:
    needs: deploy
    runs-on: ubuntu-latest
    steps:
      - name: Authenticate with Linkarooie API
        uses: ./.github/actions/linkarooie-auth
        with:
          api-key: ${{ secrets.LINKAROOIE_API_KEY }}
      - name: Update Linkarooie Resources
        uses: ./.github/actions/update-linkarooie-resources
        with:
          stage: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}

This implementation will greatly improve our development workflow, ensuring that our SST deployments are smooth and that our Linkarooie resources are always in sync with our latest changes.

@loftwah loftwah changed the title Create GitHub Actions for SST with Linkarooie API Implement GitHub Actions for SST Deployment with Linkarooie API Integration Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant