Using GitHub Actions with Architect

Simon MacDonald’s avatar

by Simon MacDonald
@macdonst
@macdonst@mastodon.online
on

GitHub actions

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. We’ve recently created some composite actions to test every pull request to your repository and deploy tagged releases to production.

Composite GitHub Actions

Composite actions are one of three different types of GitHub Actions that can be created. The main difference is that a composite action’s action.yml -> runs property contains a list of steps to run instead of a program to execute.

Architect Actions

To make continuous integration and deployment easier, we’ve released two composite actions, architect/action-build and architect/action-deploy, that you can use in your workflows. action-build is meant to be used for CI of commits and pull requests. When activated, the action will:

action-build is meant to be used as for CI of commits and pull requests. When activated the action will:

  1. Checkout your project
  2. Set up node.js v14
  3. Installs dependencies (works with npm, pnpm and yarn)
  4. Runs npm run vendor if present
  5. Runs arc hydrate
  6. Runs npm test

action-deploy is meant to be used for CD. Commits that land in the main branch of your repo will be deployed to staging, while tags will kick off a deployment to production. When activated, the action will:

  1. Checkout your project
  2. Set up node.js v14
  3. Installs dependencies (works with npm, pnpm and yarn)
  4. Runs npm run vendor if present
  5. Deploys to staging if the commit is to the main branch.
  6. Deploys to production if the git tag starts with v.

Sample Action

Here is the smallest CI/CD action you can set up to automatically test and deploy your architect project. We encourage you to use this as a jumping-off point for your actions. For instance, you might want to add notifications to Discord or Slack to report the build’s status.

name: Node CI

# Push tests pushes; PR tests merges
on: [ push, pull_request ]

jobs:
  # Test the build
  build:
    # Setup
    runs-on: ubuntu-latest

    # Go
    steps:
      - name: Build App
        uses: architect/action-build@v3

  # Assuming all that went fine (and it's main): deploy!
  deploy:
    # Setup
    needs: build
    if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest

    # Go
    steps:
      - name: Deploy app
        uses: architect/action-deploy@v1
        with:
          aws_access_key_id: ${{secrets.AWS_ACCESS_KEY_ID}}
          aws_secret_access_key: ${{secrets.AWS_SECRET_ACCESS_KEY}}

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set in your GitHub repository or organization secrets.