diff --git a/.github/workflows/build-and-release-docs.yaml b/.github/workflows/build-and-release-docs.yaml new file mode 100644 index 0000000..55b1456 --- /dev/null +++ b/.github/workflows/build-and-release-docs.yaml @@ -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/configure-aws-credentials@v1.7.0 + 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 diff --git a/.github/workflows/rebase-dev.yaml b/.github/workflows/rebase-dev.yaml new file mode 100644 index 0000000..11e8c02 --- /dev/null +++ b/.github/workflows/rebase-dev.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2a5e9e3..99da0ad 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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: @@ -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/workflow-dispatch@v1.2.4 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/configure-aws-credentials@v1.7.0 + 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/workflow-dispatch@v1.2.4 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