# Managing Infrastructure-as-Code on Git

By integrating with Bricks Action, teams can automate Blueprint management commands (such as `bp bump` and `bp publish`) to the CI workflow, allowing them to **focus on coding modules** while optimizing collaboration and automation.

Bluebricks recommends triggering the `updateci` command when a Pull Request (PR) is opened and approved or when a Git tag is assigned (e.g., for versioning).

## Recommended Workflow Described

Below is a suggested opinionated workflow that can be modified according to the team's needs:

1. Each PR Open event creates a dependency validation and preview changes which are being added to the PR as a comment
2. On PR Approve event, Bircks Action will bump versions, update the blueprints and publish recursively
3. Once the publish is completed, Bricks Action will update the PR with another commit, including the new versions.
4. On a merge event, Bricks Action won't take any action.

<figure><img src="/files/O70pYdrntoCaBGDIfAUy" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Attention:** The `updateci` command **automatically commits version updates** once the **Blueprint/Artifact is published**.

This ensures that:\
✅ **Version changes are tracked** in Git.\
✅ **Consistency is maintained** across CI/CD workflows.\
✅ **Automation remains seamless** without manual intervention.

Teams can integrate `updateci` into their **CI/CD pipelines** to streamline **Blueprint versioning and publishing**. 🚀
{% endhint %}

## Action File Example

```
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 }}
```

<figure><img src="/files/b3xashzzg1sUhFkmROQC" alt=""><figcaption><p>Example of a run workflow</p></figcaption></figure>

<figure><img src="/files/Cei2yhlheCkTI0xfHCyC" alt=""><figcaption></figcaption></figure>


---

# 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/managing-infrastructure-as-code-on-git.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.
