Skip to content

Optimize Github Actions #94

@supermaxiste

Description

@supermaxiste

Based on recommendations from @cmdoret and @rmfranken. Feel free to add anything I missed.

docker_publish.yml

Time optimization:

Code redundancy:

  • Add env variable to compute whether to push the image or not and add it as parameter in the action

Example:

env:
  REGISTRY: ghcr.io
  MAIN: ${{ github.ref == 'refs/heads/main' }}
    [...]
      - name: Build Docker image
        uses: docker/build-push-action@v5.0.0
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          file: .docker/Dockerfile
          push: ${{ env.MAIN }}

sphynx_docs.yml

Code redundancy:

Example:

name: docs
on:
  push:
    branches: [main]
  pull_request:
    paths:
      - 'docs/**'
  
permissions:
    contents: write
jobs:
  docs-build:
    runs-on: ubuntu-latest
    steps:
      # https://github.com/actions/checkout
      - uses: actions/checkout@v4
      
      # https://github.com/actions/setup-python
      - uses: actions/setup-python@v4
      
      # https://github.com/snok/install-poetry
      - name: Install Poetry
        uses: snok/install-poetry@v1

      - name: Install dependencies
        run: |
          poetry install --with doc

      - name: Sphinx build
        run: |
          make doc

      - name: Archive docs artifacts
        uses: actions/upload-artifact@v3
        with:
          name: sphynx_docs
          path: docs/**

  docs-push:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      # https://github.com/actions/checkout
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v3
         with:
             name: sphynx_docs

      # https://github.com/peaceiris/actions-gh-pages
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/docs-website' }}
        with:
          publish_branch: gh-pages
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: docs/_build/
          force_orphan: true

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions