mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 23:49:07 +00:00
refactor: use github app instead of pushing benchmarks via PR (#1052)
* refactor: use github app instead of pushing benchmarks via PR * refactor: update github app bot git email
This commit is contained in:
parent
a2aa743947
commit
d0a42a2698
1 changed files with 34 additions and 35 deletions
69
.github/workflows/docs.yml
vendored
69
.github/workflows/docs.yml
vendored
|
@ -18,7 +18,6 @@ jobs:
|
||||||
contents: write # to let mkdocs write the new docs
|
contents: write # to let mkdocs write the new docs
|
||||||
pages: write # to deploy to Pages
|
pages: write # to deploy to Pages
|
||||||
id-token: write # to verify the deployment originates from an appropriate source
|
id-token: write # to verify the deployment originates from an appropriate source
|
||||||
pull-requests: write # to merge to master via PR
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Only run in original repo (not in forks)
|
# Only run in original repo (not in forks)
|
||||||
if: github.repository == 'django-components/django-components'
|
if: github.repository == 'django-components/django-components'
|
||||||
|
@ -28,29 +27,38 @@ jobs:
|
||||||
# SETUP
|
# SETUP
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
|
# Authenticate with git with the Github App that has permission
|
||||||
|
# to push to master, in order to push benchmark results.
|
||||||
|
# See https://stackoverflow.com/a/79142962/9788634
|
||||||
|
- uses: actions/create-github-app-token@v1
|
||||||
|
id: app-token
|
||||||
|
with:
|
||||||
|
app-id: ${{ vars.RELEASE_BOT_APP_ID }}
|
||||||
|
private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git account
|
||||||
|
run: |
|
||||||
|
git config user.name components-release-bot
|
||||||
|
git config user.email "components-release-bot@users.noreply.github.com"
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.13"
|
python-version: "3.13"
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
|
|
||||||
- name: Install Hatch
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip wheel
|
python -m pip install --upgrade pip wheel
|
||||||
python -m pip install -q hatch pre-commit asv
|
python -m pip install -q hatch pre-commit asv
|
||||||
hatch --version
|
hatch --version
|
||||||
|
|
||||||
- name: Configure git
|
|
||||||
run: |
|
|
||||||
# required for "mike deploy" command below which pushes to gh-pages
|
|
||||||
git config user.name github-actions
|
|
||||||
git config user.email github-actions@github.com
|
|
||||||
|
|
||||||
###########################################
|
###########################################
|
||||||
# RECORD BENCHMARK - ONLY ON PUSH TO MASTER
|
# RECORD BENCHMARK - ONLY ON PUSH TO MASTER
|
||||||
###########################################
|
###########################################
|
||||||
|
@ -121,43 +129,34 @@ jobs:
|
||||||
asv publish
|
asv publish
|
||||||
echo "Benchmarks site DONE."
|
echo "Benchmarks site DONE."
|
||||||
|
|
||||||
# Stage and commit benchmark results
|
# Commit benchmark results
|
||||||
# 1. Create a new branch and commit benchmark results
|
|
||||||
echo "Staging and committing benchmark results..."
|
echo "Staging and committing benchmark results..."
|
||||||
# Add timestamp to make branch name unique
|
|
||||||
TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
|
||||||
BRANCH_NAME="benchmark-${TAG}-${TIMESTAMP}"
|
|
||||||
git checkout -b "${BRANCH_NAME}"
|
|
||||||
git add .asv/results/
|
git add .asv/results/
|
||||||
git add docs/benchmarks/
|
git add docs/benchmarks/
|
||||||
git commit -m "Add benchmark results for ${TAG}"
|
git commit -m "Add benchmark results for ${TAG}"
|
||||||
echo "Benchmark results committed."
|
echo "Benchmark results committed."
|
||||||
|
|
||||||
# 2. Push to the new branch
|
# Push to the new branch
|
||||||
echo "Pushing benchmark results to new branch..."
|
echo "Pushing benchmark results..."
|
||||||
git push -u origin "${BRANCH_NAME}"
|
git push origin master
|
||||||
|
|
||||||
# 3. Create a PR
|
|
||||||
PR_URL="$(gh pr create --title "chore: Add benchmark results for ${TAG}" --body "Add benchmark results for ${TAG}" --base master)"
|
|
||||||
echo "PR URL: ${PR_URL}"
|
|
||||||
|
|
||||||
# 4. Wait for the PR status checks to pass
|
|
||||||
gh pr checks "${PR_URL}" --watch
|
|
||||||
|
|
||||||
# 5. Merge the PR and delete the branch
|
|
||||||
gh pr merge "${PR_URL}" --admin --squash --delete-branch
|
|
||||||
echo "Benchmark results pushed to master."
|
echo "Benchmark results pushed to master."
|
||||||
|
|
||||||
# 6. Go back to the original branch
|
###########################################
|
||||||
git checkout master
|
# BUILD & RELEASE DOCS
|
||||||
git pull origin master
|
###########################################
|
||||||
|
|
||||||
##############################
|
# Change git authentication to Github Actions, so the rest of the
|
||||||
# BUILD & DEPLOY DOCS
|
# workflow will have lower privileges.
|
||||||
##############################
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Create Virtual Environment
|
- name: Configure git
|
||||||
run: hatch env create docs
|
run: |
|
||||||
|
# required for "mike deploy" command below which pushes to gh-pages
|
||||||
|
git config user.name github-actions
|
||||||
|
git config user.email github-actions@github.com
|
||||||
|
|
||||||
# Conditions make sure to select the right step, depending on the job trigger.
|
# Conditions make sure to select the right step, depending on the job trigger.
|
||||||
# Only one of the steps below will run at a time. The others will be skipped.
|
# Only one of the steps below will run at a time. The others will be skipped.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue