Skip to content

Codex auto-update 3 (wip) #3

Codex auto-update 3 (wip)

Codex auto-update 3 (wip) #3

Workflow file for this run

name: Codex Update
on:
schedule:
- cron: '0 9 * * *'
workflow_dispatch:
push:
branches:
- ish/codex-autoupdate
env:
CODEX_PACKAGE: '@openai/codex'
jobs:
check:
runs-on: ubuntu-latest
outputs:
should_update: ${{ steps.check.outputs.should_update }}
version: ${{ steps.check.outputs.version }}
branch: ${{ steps.check.outputs.branch }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if update is required
id: check
run: |
if ! npm outdated ${{ env.CODEX_PACKAGE }}; then
echo "Package is up to date"
exit 0
fi
LATEST=$(npm view ${{ env.CODEX_PACKAGE }} version)
BRANCH="codex-update/$LATEST"
if git ls-remote --exit-code --heads origin "refs/heads/$BRANCH" >/dev/null 2>&1; then
echo "Branch $BRANCH already exists"
exit 0
fi
echo "version=$LATEST" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "should_update=true" >> $GITHUB_OUTPUT
update:
needs: check
if: needs.check.outputs.should_update == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure git user and prepare branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${{ needs.check.outputs.branch }}"
- name: Install new version of package and commit
run: |
npm install ${{ env.CODEX_PACKAGE }}@${{ needs.check.outputs.version }}
npm run generate-types
git add package.json package-lock.json src/app-server
git commit -m "Update codex to ${{ needs.check.outputs.version }}"
- name: Push and create PR
env:
GH_TOKEN: ${{ secrets.GH_CREATE_PR_TOKEN }}
run: |
git push origin "${{ needs.check.outputs.branch }}"
gh pr create --title "Update codex to ${{ needs.check.outputs.version }}" --body "Automated codex update" --label "codex-update"