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

Optimize Github Actions #94

Open
3 tasks
supermaxiste opened this issue Oct 20, 2023 · 1 comment
Open
3 tasks

Optimize Github Actions #94

supermaxiste opened this issue Oct 20, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@supermaxiste
Copy link
Member

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
@supermaxiste supermaxiste added the enhancement New feature or request label Oct 20, 2023
@supermaxiste supermaxiste self-assigned this Oct 20, 2023
@cmdoret
Copy link
Member

cmdoret commented Oct 20, 2023

These are very good ideas! I especially like the use of artifacts for docs.

For docker, we could also gain time by using GitHub action's layer caching system: https://depot.dev/blog/docker-layer-caching-in-github-actions#docker-layer-caching-in-github-actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants