-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1932 from ORCID/feat/github-actions-workflow-to-b…
…uild-orcid-angular feat/github-actions-workflow-to-build-orcid-angular
- Loading branch information
Showing
11 changed files
with
576 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,73 @@ | ||
name: bld_all | ||
|
||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version_tag: | ||
description: 'version tag to use' | ||
required: false | ||
default: 'next_tag' | ||
type: string | ||
|
||
workflow_dispatch: | ||
inputs: | ||
version_tag: | ||
description: 'version tag to use' | ||
required: false | ||
default: 'next_tag' | ||
type: string | ||
|
||
jobs: | ||
bld_prod: | ||
uses: ./.github/workflows/bld_maven.yml | ||
secrets: inherit # pass all secrets | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
with: | ||
artifact_name: prod | ||
version_tag: ${{ inputs.version_tag }} | ||
|
||
bld_sandbox: | ||
uses: ./.github/workflows/bld_maven.yml | ||
secrets: inherit # pass all secrets | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
with: | ||
artifact_name: sandbox | ||
version_tag: ${{ inputs.version_tag }} | ||
|
||
bld_qa: | ||
uses: ./.github/workflows/bld_maven.yml | ||
secrets: inherit # pass all secrets | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
with: | ||
artifact_name: qa | ||
version_tag: ${{ inputs.version_tag }} | ||
|
||
bld_int: | ||
uses: ./.github/workflows/bld_maven.yml | ||
secrets: inherit # pass all secrets | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
with: | ||
artifact_name: int | ||
version_tag: ${{ inputs.version_tag }} |
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,111 @@ | ||
name: bld_maven | ||
run-name: bld-{{ inputs.artifact_name }} | ||
|
||
permissions: | ||
checks: write | ||
contents: read | ||
issues: read | ||
pull-requests: write | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
artifact_name: | ||
description: 'Name of the artifact env' | ||
required: false | ||
default: 'prod' | ||
type: string | ||
version_tag: | ||
description: 'Name of the tag to build' | ||
required: false | ||
default: 'v2.0.1' | ||
type: string | ||
|
||
workflow_dispatch: | ||
inputs: | ||
artifact_name: | ||
description: 'Name of the artifact env' | ||
required: false | ||
default: 'prod' | ||
type: string | ||
version_tag: | ||
description: 'Name of the tag to build' | ||
required: false | ||
default: 'v2.0.1' | ||
type: string | ||
|
||
jobs: | ||
bld_maven: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: find next version | ||
id: version | ||
uses: ORCID/version-bump-action@main | ||
with: | ||
version_tag: ${{ inputs.version_tag }} | ||
|
||
- name: Set up Open JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
cache: 'maven' | ||
|
||
- name: setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 'v16.13.2' | ||
#18.7.0 | ||
|
||
- name: show path | ||
run: | | ||
echo "$PATH" | ||
which java | ||
echo "$JAVA_HOME" | ||
echo "$tag_numeric" | ||
echo "$project" | ||
shell: bash | ||
env: | ||
version_tag_numeric: '${{ steps.version.outputs.version_tag_numeric }}' | ||
project: '${{ inputs.artifact_name }}' | ||
|
||
- name: bump version | ||
run: | | ||
mvn -T 1C --batch-mode versions:set \ | ||
-DnewVersion="$version_tag_numeric" -DgenerateBackupPoms=false --activate-profiles "${build_env}" -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | ||
env: | ||
version_tag_numeric: '${{ steps.version.outputs.version_tag_numeric }}' | ||
build_env: '${{ inputs.artifact_name }}' | ||
|
||
- name: check some build related things | ||
run: | | ||
cat /home/runner/.m2/settings.xml | ||
git --version | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<>" | ||
git status | ||
git diff | ||
- name: build our project and deploy | ||
run: | | ||
mvn -T 1C --batch-mode \ | ||
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | ||
--settings settings-deploy.xml \ | ||
--file "pom.xml" \ | ||
-DaltReleaseDeploymentRepository="github::${ARTIFACT_URL}${ARTIFACT_REPO_PATH}" \ | ||
--activate-profiles "${build_env}" -Dnodejs.workingDirectory=. \ | ||
deploy -Dmaven.test.skip | ||
echo "------------------------------------------------------" | ||
find . -name '*.war' | ||
find . -name '*.jar' | ||
env: | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||
ARTIFACT_URL: '${{ secrets.ARTIFACT_URL }}' | ||
ARTIFACT_REPO_PATH: '${{ secrets.ARTIFACT_REPO_PATH }}' | ||
ARTIFACT_USER: '${{ secrets.ARTIFACT_USER }}' | ||
ARTIFACT_PASSWORD: '${{ secrets.ARTIFACT_PASSWORD }}' | ||
build_env: '${{ inputs.artifact_name }}' |
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,22 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-added-large-files | ||
name: check for added large files | ||
description: prevents giant files from being committed. | ||
entry: check-added-large-files | ||
language: python | ||
stages: [commit, push, manual] | ||
|
||
- repo: local # Use a local repository | ||
hooks: | ||
- id: actionlint | ||
name: Lint GitHub Actions workflow files | ||
description: Runs actionlint to lint GitHub Actions workflow files | ||
entry: actionlint | ||
language: golang | ||
additional_dependencies: | ||
[github.com/rhysd/actionlint/cmd/[email protected]] | ||
types: ['yaml'] | ||
files: '^.github/workflows/' |
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,5 @@ | ||
nodejs 18.7.0 | ||
java temurin-11.0.15+10 | ||
maven 3.6.3 | ||
mvnd 0.9.0 | ||
awscli 2.9.15 |
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,116 @@ | ||
#!/usr/bin/env bash | ||
|
||
# exit on errors | ||
set -o errexit -o errtrace -o nounset -o functrace -o pipefail | ||
shopt -s inherit_errexit 2>/dev/null || true | ||
trap 'sk-catch --exit_code $? --line $LINENO --linecallfunc "$BASH_COMMAND" --funcstack $(printf "::%s" ${FUNCNAME[@]}) -o stdout ' ERR | ||
|
||
# import shellkit functions | ||
source shellkit_bootstrap.sh | ||
|
||
# defaults | ||
current_dir=`pwd` | ||
checkout_name=$(basename `pwd`) | ||
NAME="$(basename "${0}")" | ||
build_envs="prod sandbox qa int" | ||
tag="v2.0.1" | ||
|
||
# | ||
# functions | ||
# | ||
|
||
usage(){ | ||
I_USAGE=" | ||
Usage: ${NAME} [OPTIONS] | ||
Description: | ||
Build orcid-angular war files for each environment and then deploy to and artifact repo | ||
NOTE: credentials for the artifact repo are sourced from aws secrets but you still need your aws api access to be configured | ||
secretid is stored in shellkit.conf | ||
General usage: | ||
${NAME} -t vx.x.x | ||
Required options: | ||
-t | --tag ) tag ($tag) | ||
-b | --build_envs ) build environments to use ($build_envs) | ||
" | ||
echo "$I_USAGE" | ||
exit | ||
|
||
} | ||
|
||
# | ||
# args | ||
# | ||
|
||
while : | ||
do | ||
case ${1-default} in | ||
--*help|-h ) usage ; exit 0 ;; | ||
-t | --tag ) tag=$2; shift 2 ;; | ||
-b | --build_envs ) build_envs=$2; shift 2 ;; | ||
-v | --verbose ) verbose_arg='-v' VERBOSE=$((VERBOSE+1)); shift ;; | ||
--) shift ; break ;; | ||
-*) echo "WARN: Unknown option (ignored): $1" >&2 ; shift ;; | ||
*) break ;; | ||
esac | ||
done | ||
|
||
sk-arg-check tag | ||
|
||
tag_numeric=$(echo "$tag" | tr -dc '[:digit:].') | ||
echo_log "building for: $tag_numeric" | ||
|
||
# | ||
# setup build environment from .tool-versions | ||
# | ||
echo_log "configure build environment for orcid-angular $tag_numeric" | ||
|
||
sk-asdf-install-tool-versions | ||
# set JAVA_HOME | ||
. ~/.asdf/plugins/java/set-java-home.bash | ||
_asdf_java_update_java_home | ||
|
||
sk-dir-make ~/log | ||
|
||
echo $AWS_SECRET_ID | ||
# source the secrets for the artifact uploads | ||
sk-aws-secret-source $AWS_SECRET_ID | ||
|
||
echo ${ARTIFACT_URL}${ARTIFACT_REPO_PATH} | ||
|
||
export ARTIFACT_USER=$ARTIFACT_USER | ||
export ARTIFACT_PASSWORD=$ARTIFACT_PASSWORD | ||
|
||
# | ||
# build each build_env | ||
# | ||
|
||
for build_env in $build_envs;do | ||
echo_log "building $build_env" | ||
build_log_file=~/log/orcid-angular-${build_env}-${tag_numeric}.log | ||
echo_log "for build progress see $build_log_file" | ||
|
||
# set the version tag to be -${build_env}-${tag_numeric} | ||
mvn versions:set -DnewVersion="${tag_numeric}" -DgenerateBackupPoms=false --activate-profiles ${build_env} -Dnodejs.workingDirectory=. -l $build_log_file --settings settings-custom-deploy.xml | ||
|
||
# NOTE: deploy stage performs build as well as deploy | ||
mvnd --batch-mode \ | ||
--settings settings-custom-deploy.xml \ | ||
--file "pom.xml" \ | ||
-Dmaven.test.skip \ | ||
-DaltReleaseDeploymentRepository=github::${ARTIFACT_URL}${ARTIFACT_REPO_PATH} \ | ||
deploy -Dmaven.test.skip --activate-profiles ${build_env} -Dnodejs.workingDirectory=. -l $build_log_file | ||
|
||
done | ||
|
||
du -sh ~/.m2/orcid-angular-repo/ | ||
|
||
sk-time-spent | ||
|
Oops, something went wrong.