Skip to content

Commit

Permalink
Deploy docker image after build and test successful on ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyzlj committed Oct 24, 2024
1 parent 04f3826 commit a8e540d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 9 deletions.
91 changes: 82 additions & 9 deletions .github/workflows/Build_on_Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: Build on Ubuntu using GCC
on:
push:
branches:
- master
- dev
paths-ignore:
- 'data'
Expand All @@ -20,10 +21,24 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
# Container registry domain, and a name for the Docker image that this workflow builds.
IMAGE_NAME: seims
# 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
DEBIAN_DOCKERFILE: Dockerfile.TauDEMext
DEBIAN_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'latest' || 'dev-latest' }}

jobs:
build_linux:
runs-on: ubuntu-latest
build-linux:
# Check GitHub Actions runner images versions: https://github.com/actions/runner-images
runs-on: ubuntu-22.04
services:
mongodb:
image: mongo
Expand All @@ -34,13 +49,8 @@ jobs:
- name: Checkout SEIMS
uses: actions/checkout@v4

- name: Install GDAL and mongo-c-driver
run: sudo apt-get update && sudo apt-get install -qq gdal-bin libgdal-dev libmongoc-1.0-0 libmongoc-dev

- name: Setup MSMPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich
- name: Install GDAL, mongo-c-driver, and OpenMPI
run: sudo apt-get update && sudo apt-get install -qq gdal-bin libgdal-dev libmongoc-1.0-0 libmongoc-dev openmpi-bin libopenmpi-dev

- name: Checkout SEIMS
uses: actions/checkout@v4
Expand Down Expand Up @@ -109,3 +119,66 @@ jobs:
python -m scoop -n 2 demo_parameters_sensitivity.py -name youwuzhen
python -m scoop -n 2 demo_calibration.py -name youwuzhen
python -m scoop -n 2 demo_scenario_analysis.py -name youwuzhen
deploy-debian:
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 debian
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ env.DEBIAN_DOCKERFILE }}
push: true
platforms: linux/amd64
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


File renamed without changes.

0 comments on commit a8e540d

Please sign in to comment.