sdsc-ordes / gimie

Extract linked metadata from repositories
https://sdsc-ordes.github.io/gimie/
Apache License 2.0
6 stars 1 forks source link

Optimize Github Actions #94

Open supermaxiste opened 8 months ago

supermaxiste commented 8 months ago

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

docker_publish.yml

Time optimization:

Code redundancy:

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
cmdoret commented 8 months ago

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