Skip to content

Updated CI

Updated CI #42

name: CI
on:
push:
branches:
- main
pull_request:
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}
jobs:
# codecov:
# name: codecov
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Execute linters and test suites
# run: ./docker/cibuild
# - name: Upload All coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml
# fail_ci_if_error: false
python-matrix:
name: python-matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Set up conda cache
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('**/environment.yml') }}
restore-keys: ${{ runner.os }}-conda-
- name: Set up pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg', '**/requirements-dev.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Set up Conda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Update Conda's environemnt
run: conda env update -f environment.yml -n test
- name: Execute linters and test suites
run: ./scripts/cibuild
docker:
name: docker
needs:
# - codecov
- python-matrix
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run rename script if in the template repo
run: |
if [[ "$GITHUB_REPOSITORY" == */template ]]; then
scripts/rename
fi
- name: Source build args
run: |
source ./docker_env
STACTOOLS_VERSION=$(python scripts/stactools-version.py)
echo "stactools_version=$STACTOOLS_VERSION" >> $GITHUB_ENV
echo "docker_workdir=$DOCKER_WORKDIR" >> $GITHUB_ENV
echo "docker_namespace_package_dir=$DOCKER_NAMESPACE_PACKAGE_DIR" >> $GITHUB_ENV
-
name: Docker meta main
id: meta-main
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push main
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-main.outputs.tags }}
labels: ${{ steps.meta-main.outputs.labels }}
-
name: Docker meta dev
id: meta-dev
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
flavor: |
suffix=-dev
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push dev
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile-dev
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}