Repository navigation
kbdevs-sync-upstream-release #437
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: kbdevs-sync-upstream-release | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "17 */6 * * *" | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| sync: | |
| name: sync latest upstream release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Resolve latest upstream release | |
| id: upstream | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| tag="$(gh release view --repo openai/codex --json tagName -q .tagName)" | |
| fork_tag="kbdevs-${tag}" | |
| echo "tag=${tag}" >> "$GITHUB_OUTPUT" | |
| echo "fork_tag=${fork_tag}" >> "$GITHUB_OUTPUT" | |
| if git rev-parse -q --verify "refs/tags/${fork_tag}" >/dev/null; then | |
| echo "tag_exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag_exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| if gh release view "${fork_tag}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then | |
| echo "release_exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "release_exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Merge upstream release tag | |
| if: steps.upstream.outputs.tag_exists == 'false' | |
| run: | | |
| set -euo pipefail | |
| git remote add upstream https://github.com/openai/codex.git | |
| git fetch upstream --tags | |
| git checkout main | |
| git merge --no-edit "${{ steps.upstream.outputs.tag }}" | |
| git push origin main | |
| - name: Tag fork release | |
| if: steps.upstream.outputs.tag_exists == 'false' | |
| run: | | |
| set -euo pipefail | |
| git tag "${{ steps.upstream.outputs.fork_tag }}" | |
| git push origin "${{ steps.upstream.outputs.fork_tag }}" | |
| - name: Build and publish fork release | |
| if: steps.upstream.outputs.release_exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| gh workflow run kbdevs-release.yml \ | |
| --ref main \ | |
| -f tag="${{ steps.upstream.outputs.fork_tag }}" |