Skip to content

Commit

Permalink
Automate Controller update flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 16, 2024
1 parent 8ca898a commit 30d2ebc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 30d2ebc

Please sign in to comment.