Skip to content

Commit

Permalink
Add option to auto deploy to docs-latest (rerun-io#8037)
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk authored Nov 13, 2024
1 parent cf66bd0 commit bb56075
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ To get an auto-generated PR description you can put "copilot:summary" or "copilo
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.

To deploy documentation changes immediately after merging this PR, add the `deploy docs` label.
62 changes: 62 additions & 0 deletions .github/workflows/auto_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docs deploy

on:
push:
branches: [main]

permissions:
contents: "read"
id-token: "write"

defaults:
run:
shell: bash

# The lack of `concurrency` is intentional.
# We want this job to run on every commit, even if multiple are merged in a row.

jobs:
has-label:
name: Check for PR label
runs-on: ubuntu-latest
outputs:
result: ${{ steps.find-pr.outputs.result }}
steps:
- uses: actions/checkout@v3
with:
# ref - not set, because we want to end up on the merge commit
fetch-depth: 0 # don't perform a shallow clone

# Find the PR by the number in the merge commit subject line
- name: Find PR
id: find-pr
env:
GH_TOKEN: ${{ secrets.RERUN_BOT_TOKEN }}
run: |
commit_message=$(git log --pretty=format:%s -n 1 ${{ github.sha }})
pr_number=$(echo $commit_message | grep -oP '(?<=#)\d+')
result=$(gh pr view $pr_number --json labels | jq -r 'any(.labels[].name; . == "deploy docs")')
echo "result=$result" >> $GITHUB_OUTPUT
cherry-pick:
name: Cherry-pick to docs-latest
needs: [has-label]
if: needs.has-label.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.RERUN_BOT_TOKEN }}

- name: Cherry-pick
run: |
# Setup git user
git config --global user.name "rerun-bot"
git config --global user.email "[email protected]"
# Cherry-pick the commit
git checkout docs-latest
git cherry-pick ${{ github.sha }}
git push origin docs-latest
81 changes: 81 additions & 0 deletions .github/workflows/auto_docs_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Docs deploy pre-check

on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled

permissions:
contents: "read"
id-token: "write"
pull-requests: "write"

defaults:
run:
shell: bash

concurrency:
group: pr-${{ github.event.pull_request.number }}-auto-docs-check
cancel-in-progress: true

jobs:
check-cherry-pick:
name: Check if merge commit can be cherry-picked
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy docs') }}
steps:
- uses: actions/checkout@v3
with:
# ref - not set, because we want to end up on the merge commit
fetch-depth: 0 # don't perform a shallow clone

- name: Try cherry-pick
env:
GH_TOKEN: ${{ secrets.RERUN_BOT_TOKEN }}
run: |
# Setup git user
git config --global user.name "rerun-bot"
git config --global user.email "[email protected]"
git fetch origin main
git checkout main
git merge --squash origin/${{ github.event.pull_request.head.ref }}
git commit -m "${{ github.event.pull_request.head.title }} (#${{ github.event.pull_request.number }})"
commit=$(git rev-parse HEAD)
git checkout docs-latest
if git cherry-pick $commit; then
echo "Cherry-pick successful"
exit 0
else
echo "Cherry-pick failed"
printf $(git diff)
exit 1
fi
- name: Add success comment
# https://github.com/mshick/add-pr-comment
uses: mshick/[email protected]
if: success()
with:
message-id: "cherry-pick-check"
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
Your changes can be cherry-picked to `docs-latest` and will be deployed
immediately after merging.
- name: Add failure comment
# https://github.com/mshick/add-pr-comment
uses: mshick/[email protected]
if: failure()
with:
message-id: "cherry-pick-check"
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
Your changes cannot be automatically cherry-picked to `docs-latest`.
You should remove the `deploy docs` label and perform the cherry-pick manually after merging.

0 comments on commit bb56075

Please sign in to comment.