chore(release): 2.0.0 [major] #30
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: Speedrun Sync and Update | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| check_commit: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| outputs: | |
| SHOULD_RUN: ${{ steps.check_commit.outputs.SHOULD_RUN }} | |
| steps: | |
| - name: Checkout Files | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| - name: check if skip ci | |
| id: check_commit | |
| run: | | |
| COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
| if [[ "$COMMIT_MESSAGE" == *"[skip ci]"* ]]; then | |
| echo "SHOULD_RUN=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "SHOULD_RUN=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| sync-speedrun: | |
| needs: check_commit | |
| if: ${{ needs.check_commit.outputs.SHOULD_RUN != 'false' }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout Source Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Scaffold-Stark/scaffold-stark-2 | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| path: source_repo | |
| - name: Checkout Destination Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Scaffold-Stark/speedrunstark | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| path: speedrun_repo | |
| fetch-depth: 0 | |
| - name: Setup Git | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| - name: Sync Base Challenge Template Branch | |
| run: | | |
| cd speedrun_repo | |
| git checkout base-challenge-template | |
| rsync -av \ | |
| --exclude='.git/' \ | |
| --include='.github/' \ | |
| --include='.github/workflows/' \ | |
| --include='.github/workflows/main.yml' \ | |
| --exclude='.github/*' \ | |
| --exclude='.github/workflows/*' \ | |
| --exclude='__test*__' \ | |
| --exclude='packages/nextjs/public/debug-image.png' \ | |
| --exclude='packages/nextjs/public/manifest.json' \ | |
| --exclude='packages/nextjs/public/rpc-version.png' \ | |
| --exclude='packages/snfoundry/contracts/src/your_contract.cairo' \ | |
| --exclude='CHANGELOG*' \ | |
| --exclude='CONTRIBUTING*' \ | |
| --exclude='README.md' \ | |
| ../source_repo/ ./ | |
| # Sync only the Compatible versions section from README.md | |
| echo "Syncing Compatible versions section from README.md..." | |
| python3 -c " | |
| import re | |
| # Read source and destination READMEs | |
| with open('../source_repo/README.md', 'r') as f: | |
| source = f.read() | |
| with open('README.md', 'r') as f: | |
| dest = f.read() | |
| # Extract versions list from source (## Compatible versions) | |
| source_match = re.search(r'## Compatible versions\s*\n(.*?)(?=\n##|\Z)', source, re.DOTALL) | |
| if not source_match: | |
| print('Could not find Compatible versions in source README') | |
| exit(1) | |
| versions_list = source_match.group(1).strip() | |
| print('Found versions:', versions_list[:50] + '...') | |
| # Replace versions in destination (### Compatible versions) | |
| dest_pattern = r'(### Compatible versions\s*\n)(.*?)(?=\n###|\Z)' | |
| dest_match = re.search(dest_pattern, dest, re.DOTALL) | |
| if not dest_match: | |
| print('Could not find Compatible versions in destination README') | |
| exit(1) | |
| # Keep the requirements link if it exists | |
| old_content = dest_match.group(2) | |
| requirements_link = '' | |
| if 'Make sure you have the compatible versions' in old_content: | |
| req_match = re.search(r'(Make sure you have.*?)(?=\n###|\Z)', old_content, re.DOTALL) | |
| if req_match: | |
| requirements_link = '\n\n' + req_match.group(1).strip() | |
| # Replace the section | |
| new_section = dest_match.group(1) + versions_list + requirements_link | |
| new_dest = re.sub(dest_pattern, new_section, dest, flags=re.DOTALL) | |
| # Write updated README | |
| with open('README.md', 'w') as f: | |
| f.write(new_dest) | |
| print('Successfully updated Compatible versions section') | |
| " | |
| git add . | |
| git commit -m "chore: sync files from scaffold-stark-2 and update Compatible versions section" | |
| git push origin base-challenge-template | |
| - name: Notify Slack on Success | |
| if: success() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| with: | |
| channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
| slack-message: "Successfully synced scaffold-stark-2 changes to speedrunstark repository base-challenge-template branch." | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
| - name: Notify Slack on Failure | |
| if: failure() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| with: | |
| channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
| slack-message: "Failed to sync scaffold-stark-2 changes to speedrunstark repository." | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |