Skip to content

Commit

Permalink
merge main change to working branch (#77)
Browse files Browse the repository at this point in the history
* Run actions when PR is created and updated. (#74)

* refactor to support to run actions on pr

* add debug

* add docker token

* add input

* add env

* define env

* define env

* define env

* define env

* add secrets

* add secrets

* secrets inherit

* fix tag name

* fix tag name

* fix tag name

* set input required

* fix

* use vars

* fix variable

* remove debug

* Update HelloNGEN.sh (#75)

* Use image tag based on branch (#76)

* set tag name based on branch

* remove unused inputs

---------

Co-authored-by: ZacharyWills <[email protected]>
  • Loading branch information
benlee0423 and ZacharyWills authored Jan 10, 2024
1 parent a58c60f commit 49e3388
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 57 deletions.
16 changes: 12 additions & 4 deletions .github/action_templates/build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ inputs:
docker-auth-token:
description: 'Docker Hub authentication token'
required: true
github-sha:
description: 'github sha hash for tagging image'
required: true
image-name:
description: 'image name to be built'
required: true
Expand All @@ -20,6 +17,17 @@ runs:
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set env vars for main branch
shell: bash
run: |
echo "TAG_NAME=latest" >> "$GITHUB_ENV"
if: startsWith(github.ref, 'refs/heads/main')
- name: Set env vars for other branch
shell: bash
run: |
echo "TAG_NAME=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
if: ${{ !startsWith(github.ref, 'refs/heads/main') }}

- name: Login to Docker Hub
shell: bash
Expand All @@ -39,7 +47,7 @@ runs:
push: true
platforms: linux/arm64
tags: |
awiciroh/${{ inputs.image-name}}:latest
awiciroh/${{ inputs.image-name}}:${{ env.TAG_NAME}}
builder: mybuilder
no-cache: true
env:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/docker_deps_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ on:
branches: [ main ]
paths:
- docker/**
pull_request:
branches: [ main ]
paths:
- docker/**
workflow_dispatch:
workflow_call:
jobs:
build-and-push:
runs-on: self-hosted
Expand All @@ -23,6 +19,5 @@ jobs:
uses: ./.github/action_templates/build-and-push
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
github-sha: ${{ github.sha }}
image-name: "ngen-deps"
dockerfile-name: "Dockerfile.ngen-deps"
63 changes: 43 additions & 20 deletions .github/workflows/docker_image_main_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,67 @@ on:
branches: [ main ]
paths:
- docker/**
workflow_run:
workflows: [Build and push ngen image]
types:
- completed
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
on-success:
deps:
uses: ./.github/workflows/docker_deps_image.yml
secrets: inherit
troute:
needs: deps
uses: ./.github/workflows/docker_troute_image.yml
secrets: inherit
ngen:
needs: troute
uses: ./.github/workflows/docker_ngen_image.yml
secrets: inherit
final:
needs: ngen
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: deploy
uses: actions/checkout@v2
- name: Build and push Docker image
uses: ./.github/action_templates/build-and-push
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
github-sha: ${{ github.sha }}
image-name: "ciroh-ngen-image"
dockerfile-name: "Dockerfile"
- name: Publish slack message
if: always()
uses: ./.github/action_templates/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
job-status: ${{ job.status }}
pull_request_url: ${{ github.event.pull_request.html_url }}
head_commit_url: ${{ github.event.head_commit.url }}
on-failure:
check_result:
needs: final
runs-on: self-hosted
outputs:
output1: ${{ steps.step1.outputs.result }}
steps:
- id: step1
run: echo "result=success" >> "$GITHUB_OUTPUT"

slack:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
if: ${{ always() }}
needs: [deps, troute, ngen, final, check_result]
env:
OUTPUT: ${{needs.check_result.outputs.output1}}
steps:
- run: echo 'The triggering workflow failed'
- name: Set env JOBSTATUS
run: |
echo "$OUTPUT"
if [[ "success" = "$OUTPUT" ]]
then
echo "JOBSTATUS=success" >> "$GITHUB_ENV"
else
echo "JOBSTATUS=failure" >> "$GITHUB_ENV"
fi
- run: echo "$JOBSTATUS"
- name: deploy
uses: actions/checkout@v2
- name: Publish slack message
if: always()
uses: ./.github/action_templates/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
job-status: ${{ job.status }}
job-status: ${{ env.JOBSTATUS }}
pull_request_url: ${{ github.event.pull_request.html_url }}
head_commit_url: ${{ github.event.head_commit.url }}
16 changes: 3 additions & 13 deletions .github/workflows/docker_ngen_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@ on:
branches: [ main ]
paths:
- docker/**
workflow_run:
workflows: [Build and push t-route image]
types:
- completed
workflow_dispatch:
workflow_call:

jobs:
on-success:
build-and-push:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: deploy
uses: actions/checkout@v2
- name: Build and push Docker image
uses: ./.github/action_templates/build-and-push
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
github-sha: ${{ github.sha }}
image-name: "ngen"
dockerfile-name: "Dockerfile.ngen"
on-failure:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
dockerfile-name: "Dockerfile.ngen"
16 changes: 3 additions & 13 deletions .github/workflows/docker_troute_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@ on:
branches: [ main ]
paths:
- docker/**
workflow_run:
workflows: [Build and push deps image]
types:
- completed
workflow_dispatch:
workflow_call:

jobs:
on-success:
build-and-push:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: deploy
uses: actions/checkout@v2
- name: Build and push Docker image
uses: ./.github/action_templates/build-and-push
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
github-sha: ${{ github.sha }}
image-name: "t-route"
dockerfile-name: "Dockerfile.t-route"
on-failure:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
dockerfile-name: "Dockerfile.t-route"
17 changes: 16 additions & 1 deletion docker/HelloNGEN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ generate_partition() {
/dmod/bin/partitionGenerator "$1" "$2" "partitions_$3.json" "$3" '' ''
}

if [ "$2" == "auto" ]
then
echo "AUTO MODE ENGAGED"
echo "Running NextGen model framework in parallel mode"
procs=$(nproc)
procs=2 # Temporary fixed value, remove for full utilization
generate_partition "$selected_catchment" "$selected_nexus" "$procs"
mpirun -n $procs /dmod/bin/ngen-parallel $selected_catchment all $selected_nexus all $selected_realization $(pwd)/partitions_$procs.json
echo "Run completed successfully, exiting, have a nice day!"
exit 0
else
echo "Entering Interactive Mode"
continue
fi

echo -e "${YELLOW}Select an option (type a number): ${RESET}"
options=("Run NextGen model framework in serial mode" "Run NextGen model framework in parallel mode" "Run Bash shell" "Exit")
select option in "${options[@]}"; do
Expand Down Expand Up @@ -131,4 +146,4 @@ select option in "${options[@]}"; do
;;
esac
done
exit
exit

0 comments on commit 49e3388

Please sign in to comment.