-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflow to trigger METplus testing workflow (#2002)
- Loading branch information
1 parent
49fb555
commit e900334
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /bin/bash | ||
|
||
# utility function to run command get log the time it took to run | ||
function time_command { | ||
local start_seconds=$SECONDS | ||
echo "RUNNING: $*" | ||
"$@" | ||
local error=$? | ||
|
||
local duration=$(( SECONDS - start_seconds )) | ||
echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'" | ||
if [ ${error} -ne 0 ]; then | ||
echo "ERROR: '$*' exited with status = ${error}" | ||
fi | ||
return $error | ||
} | ||
|
||
prefix=refs/heads/ | ||
branch_name=${GITHUB_REF#"$prefix"} | ||
DOCKERHUB_TAG=dtcenter/met:${branch_name} | ||
|
||
DOCKERFILE_DIR=${GITHUB_WORKSPACE}/scripts/docker | ||
|
||
echo "::group::Docker Build Command" | ||
time_command docker build -t ${DOCKERHUB_TAG} \ | ||
--build-arg SOURCE_BRANCH=$branch_name \ | ||
$DOCKERFILE_DIR | ||
echo "::endgroup::" | ||
|
||
# skip docker push if credentials are not set | ||
if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then | ||
echo "DockerHub credentials not set. Skipping docker push" | ||
exit 0 | ||
fi | ||
|
||
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin | ||
|
||
echo "::group::Docker Push Command" | ||
time_command docker push ${DOCKERHUB_TAG} | ||
echo "::endgroup::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Build Docker Image and Trigger METplus Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths-ignore: | ||
- 'met/docs/**' | ||
|
||
jobs: | ||
build_met_docker: | ||
name: Handle Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build and Push Docker Image | ||
run: .github/jobs/build_and_push_docker_image.sh | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
trigger_metplus: | ||
name: Trigger METplus testing workflow | ||
runs-on: ubuntu-latest | ||
needs: build_met_docker | ||
steps: | ||
- name: Print GitHub values for reference | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
- uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.METPLUS_BOT_TOKEN }} | ||
script: | | ||
await github.rest.actions.createWorkflowDispatch({ | ||
owner: 'dtcenter', | ||
repo: 'METplus', | ||
workflow_id: 'testing.yml', | ||
ref: 'develop', | ||
inputs: { | ||
repo_name: '${{ github.repository }}', | ||
docker_tag: '${{ github.ref }}', | ||
actor: '${{ github.actor }}', | ||
commit: '${{ github.sha }}' | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ bin | |
share | ||
Makefile | ||
Makefile.in | ||
make.log | ||
|
||
# tilda files generated by emacs | ||
*~ | ||
|