Update openvm patches #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Update openvm patches" | |
on: | |
workflow_dispatch: | |
inputs: | |
STARK_BACKEND_REV: | |
description: "Optional ref for openvm-stark-backend (defaults to main head)" | |
required: false | |
OPENVM_REV: | |
description: "Optional ref for openvm (defaults to main head)" | |
required: false | |
jobs: | |
update-config: | |
name: "Update .cargo/config.toml and open a pull request" | |
runs-on: | |
["runs-on", "runner=2cpu-linux-arm64", "run-id=${{ github.run_id }}"] | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Get default STARK_BACKEND_REV from main (if none provided) | |
id: get-stark-backend-rev | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
if ("${{ github.event.inputs.STARK_BACKEND_REV }}" !== "") { | |
// If provided by user, simply return it | |
return "${{ github.event.inputs.STARK_BACKEND_REV }}"; | |
} else { | |
// Otherwise fetch latest commit of main | |
const { data } = await github.rest.repos.getCommit({ | |
owner: 'openvm-org', | |
repo: 'stark-backend', | |
ref: 'main' | |
}); | |
return data.sha; | |
} | |
- name: Get default OPENVM_REV from main (if none provided) | |
id: get-openvm-rev | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
if ("${{ github.event.inputs.OPENVM_REV }}" !== "") { | |
// If provided by user, simply return it | |
return "${{ github.event.inputs.OPENVM_REV }}"; | |
} else { | |
// Otherwise fetch latest commit of main | |
const { data } = await github.rest.repos.getCommit({ | |
owner: 'openvm-org', | |
repo: 'openvm', | |
ref: 'main' | |
}); | |
return data.sha; | |
} | |
- name: Replace placeholders in configuration | |
run: | | |
STARK_BACKEND_REV="${{ steps.get-stark-backend-rev.outputs.result }}" | |
OPENVM_REV="${{ steps.get-openvm-rev.outputs.result }}" | |
echo "Using STARK_BACKEND_REV=$STARK_BACKEND_REV" | |
echo "Using OPENVM_REV=$OPENVM_REV" | |
# Replace placeholders in template | |
sed "s|\$STARK_BACKEND_REV|${STARK_BACKEND_REV}|g" .cargo/config.template.toml > .cargo/config.tmp.toml | |
sed "s|\$OPENVM_REV|${OPENVM_REV}|g" .cargo/config.tmp.toml > .cargo/config.toml | |
rm .cargo/config.tmp.toml | |
- name: Configure git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Create or update branch | |
run: | | |
BRANCH_NAME="patch-openvm-$(date +%Y%m%d%H%M%S)" | |
git checkout -b "$BRANCH_NAME" | |
git add -f .cargo/config.toml | |
git commit -m "Patch openvm commits in .cargo/config.toml" | |
git push -u origin "$BRANCH_NAME" | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Create pull request | |
uses: repo-sync/pull-request@v2 | |
with: | |
source_branch: ${{ env.BRANCH_NAME }} | |
destination_branch: ${{ github.ref_name }} | |
pr_title: "Update .cargo/config.toml" | |
pr_body: | | |
This pull request updates .cargo/config.toml using: | |
- STARK_BACKEND_REV = ${{ steps.get-stark-backend-rev.outputs.result }} | |
- OPENVM_REV = ${{ steps.get-openvm-rev.outputs.result }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
id: create-pr-branch |