Skip to content

QuickStart ⚡

Once you've completed the Prerequisites, you can set up a basic workflow as illustrated below:

Sample-Workflow

For details on fine-tuning timeouts and other settings, please refer to the Advanced Configuration guide.

Let's get started! (follow in order)

  1. Create the refresh.yml file (see below) with inputs from Prerequisites.
  2. Manually run the refresh workflow with workflow dispatch (or wait for the cron to execute)
  3. If refresh is OK -> create ci.yml and push 🤞

Resource Pooling - reruns are faster ♻

On your first run, your provision step may take 30 to 90s due to OS startup and any pre-runner-scripts (if any). But, as we reuse runners between workflows, the instances are picked up from the pool instead 😍

Files to Create

Create - .github/workflows/refresh.yml
# in .github/workflows/refresh.yml
name: Refresh Workflow

on:
  workflow_dispatch:
  schedule:
    - cron: "*/15 * * * *"

jobs:
  refresh_job:
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@main
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Refresh Mode
        uses: fleet-actions/ec2-runner-pool-manager@main
        with:
          mode: refresh
          github-token: ${{ secrets.GH_PAT }}
          ami: ami-123
          iam-instance-profile: your-instance-profile
          security-group-ids: sg-123
          subnet-ids: subnet-123 subnet-456 subnet-789
          aws-region: us-east-1
Create - .github/workflows/ci.yml
# in .github/workflows/ci.yml
name: CI

on:
  pull_request:
    branches: ["*"]
  push:
    branches: [main]

jobs:
  provision: ### Picks up resources from pool OR creates if not available
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@main
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Provision
        id: provision_step
        uses: fleet-actions/ec2-runner-pool-manager@main
        with:
          mode: provision
          instance-count: 2

  lint:
    needs: provision
    runs-on: ${{ github.run_id }}
    steps:
      - name: run hello matrix
        run: |
          echo "hello matrix"
          pwd
          aws --version
          docker --version
          sleep 20

  test:
    needs: provision
    runs-on: ${{ github.run_id }}
    steps:
      - name: run hello matrix
        run: |
          echo "hello matrix"
          pwd
          aws --version
          docker --version
          sleep 20

  release: ### Releases used resources to pool
    needs:
      - provision
      - lint
      - test
    runs-on: ubuntu-latest
    if: ${{ always() }} # always release resources for reuse
    steps:
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@main
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Release
        id: release_mode
        uses: fleet-actions/ec2-runner-pool-manager@main
        with:
          mode: release