on:
  push:
jobs:
  build_website:
    runs-on: docker
    container:
      image: git.hswro.org/hswro/hswro_org_build:latest
    steps:
      - uses: actions/checkout@v3
      - run: bundle exec jekyll build
      - uses: actions/upload-artifact@v3
        with:
          name: generated-site
          path: _site/
  build_and_push_container:
    runs-on: docker
    if: github.ref == 'refs/heads/main'
    env:
      REGISTRY_OWNER: hswro
    container:
      image: git.hswro.org/hswro/hswro_org_build:latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/download-artifact@v3
      - run: cd generated-site && buildah build --file ../docker/serve.Dockerfile -t hswro-org:latest
      - run: buildah push --creds ${REGISTRY_OWNER}:${{ secrets.PUSH_PACKAGES_KEY }} hswro-org:latest "docker://git.hswro.org/${REGISTRY_OWNER}/hswro_org:latest"
