From 30d2ebcd21b5d1e01684b9a8469a1b3150b8e873 Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Mon, 16 Dec 2024 11:58:41 -0500 Subject: [PATCH] Automate Controller update flow --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e6dafb..a4a0f81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,3 +46,45 @@ jobs: path: "configs" destination: "c7e-prod-static/presets" parent: false + + update-controller: + needs: build + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - uses: "actions/checkout@v4" + with: + repository: cartridge-gg/controller + token: ${{ secrets.CREATE_PR_TOKEN }} + + - name: Get short SHA + id: sha + run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT + + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Create and switch to new branch + run: git checkout -b update-presets-${{ steps.sha.outputs.SHORT_SHA }} + + - name: Update package.json + run: | + jq '.dependencies["@cartridge/presets"] = "github:cartridge-gg/presets#${{ steps.sha.outputs.SHORT_SHA }}"' package.json > tmp.json && mv tmp.json package.json + + - name: Commit and push changes + run: | + git add package.json + git commit -m "chore: update @cartridge/presets to ${{ steps.sha.outputs.SHORT_SHA }}" + git push origin update-presets-${{ steps.sha.outputs.SHORT_SHA }} + + - name: Create Pull Request + env: + GITHUB_TOKEN: ${{ secrets.CREATE_PR_TOKEN }} + run: | + gh pr create \ + --title "chore: update @cartridge/presets to ${{ steps.sha.outputs.SHORT_SHA }}" \ + --body "Updates @cartridge/presets dependency to point to commit ${{ steps.sha.outputs.SHORT_SHA }}" \ + --repo cartridge-gg/controller \ + --base main