Skip to content

Commit

Permalink
Let's try using jupyterlab's galata snapshot updates workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Sep 26, 2024
1 parent 1c3528e commit 5e94497
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions .github/workflows/generate_api_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,45 @@ jobs:
run:
shell: bash -el {0}
steps:
- name: "Install jq 📦"
run: |
sudo apt update
sudo apt install -y jq
- name: "Checkout repository 🛎️"
uses: actions/checkout@v4
with:
# Must set the ref so that this works in github actions; see
# https://github.com/stefanzweifel/git-auto-commit-action/tree/master?tab=readme-ov-file#example-workflow
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: "Get PR Info"
id: pr
env:
PR_NUMBER: ${{ github.event.issue.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
COMMENT_AT: ${{ github.event.comment.created_at }}
run: |
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
head_sha="$(echo "$pr" | jq -r .head.sha)"
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
exit 1
fi
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
- name: Checkout the branch from the PR that triggered the job
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}

- name: Validate the fetched branch HEAD revision
env:
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
run: |
actual_sha="$(git rev-parse HEAD)"
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
exit 1
fi
- name: "Set up Miniconda 🐍"
uses: conda-incubator/setup-miniconda@v3
Expand All @@ -48,7 +76,13 @@ jobs:
mv docusaurus-docs/static/openapi.json.formatted docusaurus-docs/static/openapi.json
- name: "Commit changes"
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Update REST API documentation (openapi.json)'
file_pattern: 'docusaurus-docs/static/openapi.json'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git pull --no-tags
git add docusaurus-docs/static/openapi.json
git commit -m "Update REST API documentation (openapi.json)"
git config push.default upstream
git push

0 comments on commit 5e94497

Please sign in to comment.