Skip to content

Commit

Permalink
Update template CD to use Platform CLI (#768)
Browse files Browse the repository at this point in the history
Update template CD to:
- Keep lorenyu/platform-cli branch up to date with main
- Install nava-platform CLI
- Use nava-platform CLI to update platform-test repos

## Context

As part of migrating to use the Platform CLI we are going to first get
the platform-test* repos to start updating using the Platform CLI
  • Loading branch information
lorenyu authored Oct 24, 2024
1 parent 32ce571 commit 30bf67d
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions .github/workflows/template-only-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,27 @@ on:
concurrency: platform-template-only-cd

jobs:
# TODO: Get rid of this job once we've merged the platform-cli branch into the main branch
update-platform-cli-branch:
name: Update platform-cli branch
runs-on: ubuntu-latest
steps:
- name: Checkout template-infra repo
uses: actions/checkout@v4
with:
path: template-infra
ref: lorenyu/platform-cli
# Fetch history of all branches so we can merge main into the feature branch
fetch-depth: 0
- name: Update
working-directory: template-infra
run: |
git merge origin/main
git push
deploy:
name: Deploy to ${{ matrix.project_repo }}
runs-on: ubuntu-latest
needs: update-platform-cli-branch
strategy:
fail-fast: true
matrix:
Expand All @@ -25,23 +43,36 @@ jobs:
uses: actions/checkout@v4
with:
path: template-infra
# TODO: Revert to checking out main once we've merged the platform-cli branch into the main branch
ref: lorenyu/platform-cli
# Fetch history because the Platform CLI needs it to do the update
fetch-depth: 0
- name: Checkout project repo
uses: actions/checkout@v4
with:
path: project-repo
repository: ${{ matrix.project_repo }}
token: ${{ secrets.PLATFORM_BOT_GITHUB_TOKEN }}

- name: Update infra template
working-directory: project-repo
run: ../template-infra/template-only-bin/update-template
# Set up Python since built in Python version (3.10.12) is not supported by Platform CLI (<4.0,>=3.11)
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Push changes to project repo
- name: Install nava-platform CLI
run: pipx install --python python3.13 git+https://github.com/navapbc/platform-cli

- name: Configure git
working-directory: project-repo
run: |
git config user.name nava-platform-bot
git config user.email platform-admins@navapbc.com
git add --all
# Commit changes (if no changes then no-op)
git diff-index --quiet HEAD || git commit -m "Template infra deploy #${{ github.run_id }}"
git push
- name: Update infra template
working-directory: project-repo
run: nava-platform infra update --template-uri ../template-infra --version lorenyu/platform-cli .

- name: Push changes to project repo
working-directory: project-repo
run: git push

0 comments on commit 30bf67d

Please sign in to comment.