Skip to content

Commit

Permalink
build images after build on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyzlj committed Oct 10, 2024
1 parent 3b0fdcb commit 187528e
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 130 deletions.
126 changes: 116 additions & 10 deletions .github/workflows/Build_on_Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,46 @@ name: Build with OpenMPI and GDAL using GCC on Ubuntu

on:
push:
paths-ignore:
- 'data'
branches:
- 'master'
- 'dev'
paths-ignore:
- 'data'
pull_request:
paths-ignore:
paths-ignore:
- 'data'
workflow_dispatch:

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build-linux-ubuntu:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
# Container registry domain, and a name for the Docker image that this workflow builds.
# IMAGE_NAME: ${{ github.repository }} ==> crazyzlj/ccgl
IMAGE_NAME: ccgl
# github container registry
REGISTRY: ghcr.io
NAMESPACE: ${{ github.repository_owner }}
# aliyun ACR
REGION_ID_ACR: cn-hangzhou
REGISTRY_ACR: registry.cn-hangzhou.aliyuncs.com
LOGIN_SERVER: https://registry.cn-hangzhou.aliyuncs.com
NAMESPACE_ACR: ljzhu-geomodels
# dockerfiles and tags
ALPINE_DOCKERFILE: Dockerfile.alpine
ALPINE_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'alpine' || 'dev-alpine' }}
DEBIAN_DOCKERFILE: Dockerfile.debian
DEBIAN_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'debian' || 'dev-debian' }}
UBUNTU_DOCKERFILE: Dockerfile.ubuntu
UBUNTU_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'ubuntu' || 'dev-ubuntu' }}

jobs:
build-linux:
# Check GitHub Actions runner images versions: https://github.com/actions/runner-images
runs-on: ubuntu-22.04
steps:
- name: Checkout TauDEM_ext
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install GDAL and OpenMPI
run: sudo apt-get update && sudo apt-get install -qq gdal-bin libgdal-dev openmpi-bin libopenmpi-dev
Expand All @@ -37,3 +56,90 @@ jobs:
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j 4

build-and-push-image:
needs: build-linux
runs-on: ubuntu-22.04
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4
# login alibaba Container Registry
- name: Login to ACR
uses: aliyun/acr-login@v1
with:
login-server: ${{ env.LOGIN_SERVER }}
region-id: ${{ env.REGION_ID_ACR }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# login ghcr.io
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
# https://github.com/marketplace/actions/docker-setup-buildx
- uses: docker/setup-buildx-action@v3
- name: Build based on alpine
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ env.ALPINE_DOCKERFILE }}
push: true
platforms: linux/amd64,linux/arm64
provenance: false
tags: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}:${{ env.ALPINE_IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.ALPINE_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build based on debian
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ env.DEBIAN_DOCKERFILE }}
push: true
platforms: linux/amd64,linux/arm64
provenance: false
tags: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}:${{ env.DEBIAN_IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.DEBIAN_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build based on ubuntu
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ env.UBUNTU_DOCKERFILE }}
push: true
platforms: linux/amd64,linux/arm64
provenance: false
tags: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}:${{ env.UBUNTU_IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.UBUNTU_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
9 changes: 6 additions & 3 deletions .github/workflows/Build_on_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ name: Build with MSMPI and GDAL using MSVC on Windows

on:
push:
paths-ignore:
branches:
- 'master'
- 'dev'
paths-ignore:
- 'data'
pull_request:
paths-ignore:
paths-ignore:
- 'data'
workflow_dispatch:

Expand All @@ -22,7 +25,7 @@ jobs:

steps:
- name: Checkout TauDEM_ext
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup MPI (use MS-MPI)
uses: mpi4py/setup-mpi@v1
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/Build_on_macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ name: Build with OpenMPI and GDAL using AppleClang on macOS

on:
push:
paths-ignore:
branches:
- 'master'
- 'dev'
paths-ignore:
- 'data'
pull_request:
paths-ignore:
paths-ignore:
- 'data'
workflow_dispatch:

Expand All @@ -21,8 +24,8 @@ jobs:

steps:
- name: Checkout TauDEM_ext
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup xcode
uses: maxim-lobanov/setup-xcode@v1

Expand Down
113 changes: 0 additions & 113 deletions .github/workflows/delopy_images.yml

This file was deleted.

0 comments on commit 187528e

Please sign in to comment.