# Getting Started with Bricks Action

Bricks Action makes [Bricks CLI](/docs/bricks-cli/bricks-cli.md) accessible through [GitHub Actions](https://github.com/features/actions), allowing DevOps teams to run any Bricks CLI command directly within their workflows. It seamlessly automates tasks such as:

* Version bumping (`bricks bp bump`)
* Blueprint and Artifact updates and publishing (`bricks bp update`)
* Blueprint installation and uninstall (`bricks install/uninstall`)

{% hint style="info" %}
For the full list of available bricks CLI commands, please see the [bricks CLI Commands Reference](broken://pages/NlU8bDKW2TUici1gVVoA).
{% endhint %}

By integrating Bricks Action, teams can streamline CI/CD processes, ensuring efficient, automated, and scalable infrastructure management.

## Getting Started

Integrate **bricks CLI** with your **GitHub CI/CD** by following the instructions in the **bricks-action** repository on **GitHub** 🔗 <https://github.com/bluebricks-co/bricks-action>

### Prerequisites

1. **Bricks API Key**
   * **Requirement:** A valid Bluebricks Long-Lived Token (API key) is required to authenticate with the bricks service and perform version bumps, blueprint updates, and publishing operations.
   * **How to Generate:** Follow the steps outlined in the [official Bluebricks documentation](https://bluebricks.co/docs/api/authenticate/authentication).
   * **Tip:** Store your API key securely in your GitHub repository secrets as `BRICKS_API_KEY`.
2. **GitHub Token**
   * **Requirement:** The action leverages GitHub's built-in `GITHUB_TOKEN` to perform Git operations such as commits and pushes.
   * **Setup:** Ensure that your workflow has the necessary permissions (e.g., `contents: write`, `pull-requests: write`).
3. **Repository Organization**
   * Structure your repository with designated directories for artifacts and blueprints (e.g., `bluebricks/artifacts` and `bluebricks/blueprints`).
   * Prepare a Bricks configuration file (e.g., `config-dev.yaml`) with your project-specific settings.

### Usages

Bricks Action does not include built-in workflows and must be implemented based on specific use-case requirements. Below is an example of how to integrate Bricks Action within a GitHub Actions workflow:

```
name: 'Update Artifacts and Blueprints'

on:
  pull_request:
    types: [opened, synchronize, reopened]
  pull_request_review:
    types: [submitted]

permissions:
  id-token: write
  contents: write
  pull-requests: write

jobs:
  updateci:
    runs-on: ubuntu-latest
    if: |
      (github.event_name == 'pull_request') ||
      (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          persist-credentials: false
          ref: ${{ github.event.pull_request.head.ref }} # This is the PR branch

      - name: Run updateci Command
        uses: bluebricks-co/bricks-action@main
        with:
          command: 'updateci'
          artifacts-folder: 'bluebricks/packages'
          blueprints-folder: 'bluebricks/blueprints'
          artifact-bump: 'patch'
          blueprint-bump: 'patch'
          base: 'origin/master'
          api-key: ${{ secrets.BRICKS_API_KEY }}
          config-file: ${{ github.workspace }}/config-dev.yaml
          flags: ${{ github.event_name == 'pull_request' && '--dry' || '' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## Next Steps

1. [Implement Code Lifecycle Workflow using Bricks Action](/docs/orchestration/bluebricks-git-repository-guide/managing-infrastructure-as-code-on-git.md)
2. [Implement Configuration Lifecycle Workflow using Bricks Action](/docs/orchestration/bluebricks-git-repository-guide/managing-configuration-on-git.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bluebricks.co/docs/orchestration/bluebricks-git-repository-guide/getting-started-with-bricks-action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
