Update OpenCode #869
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
| # Automated Update Workflow | |
| # | |
| # OpenCode releases frequently, so we check hourly. | |
| # Pushes updates directly to main. | |
| name: Update OpenCode | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # Hourly | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@v17 | |
| with: | |
| extra-conf: | | |
| access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for updates | |
| id: check | |
| run: | | |
| output=$(nix develop --command ./update.sh 2>&1) || true | |
| echo "$output" | |
| if echo "$output" | grep -q "UPDATE_NEEDED=true"; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| new_version=$(echo "$output" | grep "NEW_VERSION=" | cut -d= -f2) | |
| echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Update version.json | |
| if: steps.check.outputs.update_needed == 'true' | |
| run: | | |
| nix develop --command ./update.sh --update | |
| - name: Validate flake | |
| if: steps.check.outputs.update_needed == 'true' | |
| run: | | |
| nix flake check | |
| - name: Push update | |
| if: steps.check.outputs.update_needed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add version.json | |
| git commit -m "chore: update opencode to ${{ steps.check.outputs.new_version }}" | |
| git push origin HEAD:main | |
| - name: Summary | |
| run: | | |
| if [[ "${{ steps.check.outputs.update_needed }}" == "true" ]]; then | |
| echo "## Update Applied" >> $GITHUB_STEP_SUMMARY | |
| echo "Updated to version ${{ steps.check.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "## No Update Needed" >> $GITHUB_STEP_SUMMARY | |
| echo "Already on the latest version" >> $GITHUB_STEP_SUMMARY | |
| fi |