From 30bf67d806fb484c41985ce990aafea97254fd17 Mon Sep 17 00:00:00 2001 From: Loren Yu Date: Thu, 24 Oct 2024 15:28:35 -0700 Subject: [PATCH] Update template CD to use Platform CLI (#768) 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 --- .github/workflows/template-only-cd.yml | 47 +++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/template-only-cd.yml b/.github/workflows/template-only-cd.yml index 261a8004..9a2a1587 100644 --- a/.github/workflows/template-only-cd.yml +++ b/.github/workflows/template-only-cd.yml @@ -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: @@ -25,6 +43,10 @@ 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: @@ -32,16 +54,25 @@ jobs: 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