build and push #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: build and push | |
on: | |
push: | |
branches: | |
- 'main' | |
schedule: | |
- cron: '0 11 * * 2' | |
pull_request: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
jobs: | |
docker: | |
name: build and push ${{ matrix.pyver }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
pyver: | |
- py38 | |
- py39 | |
- py310 | |
- py311 | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Gather metadata (test layer) | |
id: meta-test | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
shivupa/cclib-ci | |
flavor: | | |
latest=true | |
tags: | | |
type=sha,prefix=${{ matrix.pyver }}-test- | |
- | |
name: Gather metadata (CI layer) | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
shivupa/cclib-ci | |
flavor: | | |
latest=true | |
tags: | | |
type=schedule,pattern={{date 'YYYYMMDD'}},prefix=${{ matrix.pyver }}- | |
type=sha,prefix=${{ matrix.pyver }}- | |
type=edge,prefix=${{ matrix.pyver }}- | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# - | |
# name: Cache conda package download | |
# uses: actions/cache@v3 | |
# with: | |
# path: conda-pkgs | |
# key: conda-pkgs-${{ hashFiles('Containerfile') }} | |
# - | |
# name: Inject conda-pkgs into Docker | |
# uses: reproducible-containers/buildkit-cache-dance@v2.1.2 | |
# with: | |
# cache-source: conda-pkgs | |
# cache-target: /opt/conda/pkgs | |
- | |
name: Build and export to Docker (test layer) | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
PYTHON_VERSION_DIR=${{ matrix.pyver }} | |
push: false | |
load: true | |
tags: ${{ steps.meta-test.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
target: test | |
- | |
name: Build and export to Docker (CI layer) | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
PYTHON_VERSION_DIR=${{ matrix.pyver }} | |
push: false | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
target: ci | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
if: ${{ github.event_name != 'pull_request'}} | |
- | |
name: Push to DockerHub | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
PYTHON_VERSION_DIR=${{ matrix.pyver }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
if: ${{ github.event_name != 'pull_request'}} |