Skip to content

Commit

Permalink
refactor to workflow template
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Koenig <[email protected]>
  • Loading branch information
ko3n1g committed Sep 19, 2024
1 parent c35aea0 commit b7d0704
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 49 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/_build_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build NeMo Aligner container
on:
workflow_call:

defaults:
run:
shell: bash -x -e -u -o pipefail {0}

jobs:
build:
runs-on: self-hosted-builder
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}

- name: Clean runner cache
run: |
docker system prune --filter "until=24h" --force
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# We use `docker` driver as this speeds things up for
# trivial (non-multi-stage) builds.
driver: docker

- name: Pull cache images
run: |
docker pull nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number || 'buildcache' }} || true
docker pull nemoci.azurecr.io/nemo_aligner_container:buildcache || true
- name: Build and push
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
build-args: |
MAX_JOBS=32
ALIGNER_COMMIT=${{ github.event.pull_request.head.sha || github.sha }}
cache-from: |
nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number || 'buildcache' }}
nemoci.azurecr.io/nemo_aligner_container:buildcache
cache-to: type=inline
tags: nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }}

- name: Update PR image
if: github.event_name == 'pull_request'
run: |
docker tag nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }} nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number }}
docker push nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number }}
- name: Update buildcache image
if: github.ref == 'refs/heads/main'
run: |
docker tag nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }} nemoci.azurecr.io/nemo_aligner_container:buildcache
docker push nemoci.azurecr.io/nemo_aligner_container:buildcache
51 changes: 2 additions & 49 deletions .github/workflows/cicd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,5 @@ concurrency:

jobs:
build:
runs-on: self-hosted-builder
if: ${{ github.event.label.name == 'Run CICD' }}
steps:
- name: Clean runner cache
run: |
docker system prune --filter "until=24h" --force
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# We use `docker` driver as this speeds things up for
# trivial (non-multi-stage) builds.
driver: docker

- name: Pull cache images
run: |
docker pull nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number || 'buildcache' }} || true
docker pull nemoci.azurecr.io/nemo_aligner_container:buildcache || true
- name: Build and push
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
build-args: |
MAX_JOBS=32
ALIGNER_COMMIT=${{ github.event.pull_request.head.sha || github.sha }}
cache-from: |
nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number || 'buildcache' }}
nemoci.azurecr.io/nemo_aligner_container:buildcache
cache-to: type=inline
tags: nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }}

- name: Update PR image
if: github.event_name == 'pull_request'
run: |
docker tag nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }} nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number }}
docker push nemoci.azurecr.io/nemo_aligner_container:${{ github.event.pull_request.number }}
- name: Update buildcache image
if: github.ref == 'refs/heads/main'
run: |
docker tag nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }} nemoci.azurecr.io/nemo_aligner_container:buildcache
docker push nemoci.azurecr.io/nemo_aligner_container:buildcache
if: ${{ github.event.label.name == 'Run CICD' || github.ref == 'refs/heads/main' }}
uses: ./.github/workflows/_build_container.yml

0 comments on commit b7d0704

Please sign in to comment.