Update dockerfile_cpu #4
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 | |
on: | |
push: | |
branches: [ main ] | |
# Run when container or environment is changed | |
paths: | |
- containers/dockerfile_cpu | |
# Allows workflow to be manually triggered | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: cmelab/grits | |
DOCKERFILE: containers/dockerfile_cpu | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Get Latest Version | |
id: latest-version | |
run: | | |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo $LATEST_TAG | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT | |
# slice off the v, ie v0.7.2 -> 0.7.2 | |
VERSION=${LATEST_TAG:1} | |
echo $VERSION | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
- name: Print Latest Version | |
run: echo ${{ steps.latest-version.outputs.VERSION }} | |
- name: Create fully qualified image registry path | |
id: fqirp | |
run: | | |
FQIRP=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.latest-version.outputs.VERSION }} | |
echo "FQIRP=$FQIRP" >> $GITHUB_OUTPUT | |
- name: Print FQIRP | |
run: echo ${{ steps.fqirp.outputs.FQIRP }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ${{ env.DOCKERFILE }} | |
load: true | |
push: false | |
build-args: | | |
VERSION=${{ steps.latest-version.outputs.VERSION }} | |
- name: Test image | |
run: | | |
docker run --rm ${{ steps.fqirp.outputs.FQIRP }} python -c "import grits; print(grits.__version__)" | |
- name: Push Docker image | |
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
with: | |
context: . | |
file: ${{ env.DOCKERFILE }} | |
push: true | |
build-args: | | |
VERSION=${{ steps.latest-version.outputs.VERSION }} |