docker-base-images-gha #66
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: docker-base-images-gha | |
on: workflow_dispatch | |
jobs: | |
build-base-images-gha: | |
strategy: | |
fail-fast: false | |
matrix: | |
IMAGE: [ pangeo-notebook, pangeo-notebook-shared, pytorch-notebook, r-notebook, k8s-hub, nasa-veda-singleuser-init ] | |
env: | |
REGISTRY_BASE_URL: public.ecr.aws/i8x6m1u9 | |
name: ${{ matrix.IMAGE }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: sergeysova/jq-action@v2 | |
- name: configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.DEPLOY_USER_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.DEPLOY_USER_AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: create ecr repository if not | |
uses: int128/create-ecr-repository-action@v1 | |
with: | |
repository: ${{ matrix.IMAGE }} | |
public: true | |
- name: set the tags for docker | |
id: tags | |
run: | | |
DATESTR=$(date +%F) | |
datetag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:$DATESTR | |
echo "datetag=${datetag}" >>$GITHUB_OUTPUT | |
DIGEST=$(sha256sum ./docker-images/base/${{ matrix.IMAGE }}/Dockerfile | cut -d' ' -f1) | |
digesttag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:$DIGEST | |
echo "digesttag=${digesttag}" >>$GITHUB_OUTPUT | |
latesttag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:latest | |
echo "latesttag=${latesttag}" >>$GITHUB_OUTPUT | |
- name: check for changes | |
id: changes | |
run: | | |
if ! git diff --quiet HEAD~ -- ./docker-images/base/${{ matrix.IMAGE }}; then | |
echo "./docker-images/base/${{ matrix.IMAGE }} changed, building!" | |
echo "build=true" >>$GITHUB_OUTPUT | |
else | |
echo "build=false" >>$GITHUB_OUTPUT | |
fi | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v2 | |
if: ${{ steps.changes.outputs.build == 'true' }} | |
- name: docker login for ecr | |
run: | |
aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws | |
if: ${{ steps.changes.outputs.build == 'true' }} | |
- name: docker build image | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
context: ./docker-images/base/${{ matrix.IMAGE }} | |
tags: | | |
${{ steps.tags.outputs.datetag }} | |
${{ steps.tags.outputs.digesttag }} | |
${{ steps.tags.outputs.latesttag }} | |
if: ${{ steps.changes.outputs.build == 'true' }} |