Skip to content

Commit

Permalink
ci(docker-build): add step to build base first, then generic and anac…
Browse files Browse the repository at this point in the history
…onda images
  • Loading branch information
vpayno committed Mar 30, 2024
1 parent 8e254d5 commit 02d3d49
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,52 @@ jobs:
# Set the output named "docs_changed"
printf "%s=%s\n" "docs_changed" "${HAS_DIFF}" >> "${GITHUB_OUTPUT}"
stage2:
name: Docker Build
stage2a:
name: Docker Build Base Image
strategy:
matrix:
os: ["ubuntu-latest"]
image:
- ci-base-debian
runs-on: "${{ matrix.os }}"
needs: [stage1]
if: needs.stage1.outputs.docs_changed == 'True'
outputs:
tag_date: ${{ steps.setup_image_info.outputs.tag_date }}
steps:
- name: Setup Env [${{ matrix.os }} - ${{ matrix.image }}]
id: setup_image_info
run: |-
tag_date="$(date +%Y%m%d)"
printf "%s=%s\n" "tag_date" "${tag_date}" >> "${GITHUB_OUTPUT}"
- name: Docker Build Checkout [${{ matrix.os }} - ${{ matrix.image }}]
uses: actions/checkout@v3
- name: Login to Docker Hub [${{ matrix.os }} - ${{ matrix.image }}]
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx [${{ matrix.os }} - ${{ matrix.image }}]
uses: docker/setup-buildx-action@v2
- name: Build and push [${{ matrix.os }} - ${{ matrix.image }}]
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ steps.setup_image_info.outputs.tag_date }}
target: ${{ matrix.image }}
cache-to: type=gha
stage2b:
name: Docker Build CI Images
strategy:
matrix:
os: ["ubuntu-latest"]
image:
- ci-generic-debian
- ci-anaconda-debian
runs-on: "${{ matrix.os }}"
needs: [stage1]
needs: [stage1, stage2a]
if: needs.stage1.outputs.docs_changed == 'True'
outputs:
tag_date: ${{ steps.setup_image_info.outputs.tag_date }}
Expand All @@ -131,6 +167,7 @@ jobs:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ steps.setup_image_info.outputs.tag_date }}
target: ${{ matrix.image }}
cache-from: type=gha
stage3:
name: Docker Build Check
env:
Expand All @@ -139,12 +176,12 @@ jobs:
matrix:
os:
- vpayno/ci-generic-debian:latest
- vpayno/ci-generic-debian:${{ needs.stage2.outputs.tag_date }}
- vpayno/ci-generic-debian:${{ needs.stage2b.outputs.tag_date }}
- vpayno/ci-anaconda-debian:latest
- vpayno/ci-anaconda-debian:${{ needs.stage2.outputs.tag_date }}
- vpayno/ci-anaconda-debian:${{ needs.stage2b.outputs.tag_date }}
runs-on: ubuntu-latest
container: ${{ matrix.os }}
needs: [stage2]
needs: [stage2b]
steps:
- name: Test New Container [${{ matrix.os }}]
run: |-
Expand Down

0 comments on commit 02d3d49

Please sign in to comment.