Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix documentation release and add auto rebase #4

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/build-and-release-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build And Release Docs

on: workflow_dispatch

env:
AWS_REGION: eu-west-2
AWS_OIDC_ROLE_ARN: arn:aws:iam::980416368045:role/GitHubAction-AssumeRoleWithAction
DOCS_UPLOAD_URL: s3://sachahu.com/docs/Github-Search-Engine

jobs:

build-release-docs:
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "^3.11.0"
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --only documentation

- name: configure aws credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Build and Deploy docs
run: |
poetry run sphinx-build -M html docs/source/ docs/build

aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/pages/v$(poetry version --short) --delete

if [[ "${GITHUB_REF##*/}" == "main" ]]; then
aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/latest --delete
fi

rm -rf docs/build
24 changes: 24 additions & 0 deletions .github/workflows/rebase-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Automatic Rebase

on: workflow_dispatch

jobs:
rebase:
name: Rebase
runs-on: ubuntu-latest
steps:
- name: Set up Git for GITHUB_TOKEN
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Authenticate with GITHUB_TOKEN
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git

- name: Rebase dev onto main
run: |
git checkout dev
git fetch origin main
git rebase origin/main
git push --force-with-lease
63 changes: 19 additions & 44 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: Release

on:
workflow_run:
workflows: ["Run Tests"]
types: [completed]
push:
branches:
- main
- dev

env:
AWS_REGION: eu-west-2
AWS_OIDC_ROLE_ARN: arn:aws:iam::980416368045:role/GitHubAction-AssumeRoleWithAction
DOCS_UPLOAD_URL: s3://sachahu.com/docs/Github-Search-Engine
PROJECT_NAME : Github-Search-Engine

jobs:
Expand Down Expand Up @@ -72,47 +67,27 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

build-release-docs:
trigger-docs:
runs-on: ubuntu-latest
needs:
- release
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
actions: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Invoke Documentation Workflow
uses: benc-uk/[email protected]
with:
fetch-depth: 0
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "^3.11.0"
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --only documentation
workflow: Build And Release Docs

- name: configure aws credentials
uses: aws-actions/[email protected]
trigger-rebase:
runs-on: ubuntu-latest
needs:
- release
permissions:
actions: write
steps:
- name: Invoke rebase Workflow
if: ${{ github.ref == 'refs/heads/main' }}
uses: benc-uk/[email protected]
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Build and Deploy docs
run: |
poetry run sphinx-build -M html docs/source/ docs/build

aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/pages/v$(poetry version --short) --delete
aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/latest --delete

rm -rf docs/build

workflow: Automatic Rebase