issue/hitide-ui-44: cleaned up footprint/preview display code #231
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
# This is the main build pipeline that verifies and publishes the software | |
name: Build | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push events | |
push: | |
branches: | |
- main | |
- develop | |
- 'release/**' | |
- 'feature/**' | |
- 'issue/**' | |
- 'issues/**' | |
- 'dependabot/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
allow_same_version: | |
description: 'Allow the same version to be built' | |
required: false | |
default: 'false' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
PROJECT_ NAME: podaac/hitide-ui | |
jobs: | |
# First job in the workflow installs and verifies the software | |
build: | |
name: Build, Test, Deploy | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout | |
- name: Checkout project to build and deploy | |
uses: actions/checkout@v4 | |
## Read the json file into the environment variables | |
- name: JSON to variables | |
uses: rgarcia-phi/[email protected] | |
with: | |
filename: 'package.json' | |
prefix: project | |
## Set environment variables | |
- name: Configure Initial YAML file and environment variables | |
run: | | |
echo "THE_VERSION=${{ env.project_version }}" >> $GITHUB_ENV; | |
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV; | |
GITHUB_REF_READABLE="${GITHUB_REF//\//-}" | |
echo "GITHUB_REF_READABLE=${GITHUB_REF_READABLE}" >> $GITHUB_ENV | |
## NPM Tagging | |
- name: Pre Alpha | |
if: | | |
startsWith(github.ref, 'refs/heads/issue') || | |
startsWith(github.ref, 'refs/heads/dependabot/') || | |
startsWith(github.ref, 'refs/heads/feature/') | |
run: | | |
echo "THE_ENV=sit" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV | |
echo "THE_VERSION=$(npm --no-git-tag-version --allow-same-version version ${{ env.THE_VERSION }}-${GITHUB_SHA})" >> $GITHUB_ENV | |
## Set Alpha variables | |
- name: Alpha | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
echo "THE_ENV=sit" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV | |
echo "THE_VERSION=$(npm --no-git-tag-version version prerelease)" >> $GITHUB_ENV | |
## Bump RC Version | |
- name: Bump rc version | |
# If triggered by push to a release branch | |
if: ${{ startsWith(github.ref, 'refs/heads/release/') }} | |
env: | |
# True if the version already has a 'rc' pre-release identifier | |
BUMP_RC: ${{ contains(env.project_version, 'rc') }} | |
RELEASE_VERSION: ${THE_BRANCH//*\/} | |
run: | | |
if [ "$BUMP_RC" == true ]; then | |
echo "THE_VERSION=$(npm --no-git-tag-version version prerelease --preid rc)" >> $GITHUB_ENV | |
else | |
echo "THE_VERSION=$(npm --no-git-tag-version version ${GITHUB_REF#refs/heads/release/}-rc.1)" >> $GITHUB_ENV | |
fi | |
echo "THE_ENV=uat" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=UAT" >> $GITHUB_ENV | |
## Set Release variables | |
- name: Release | |
if: ${{ (startsWith(github.ref, 'refs/heads/main')) && (github.event.inputs.allow_same_version != 'true') }} | |
run: | | |
echo "THE_ENV=ops" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=OPS" >> $GITHUB_ENV | |
echo "Modifying version number ${{ env.project_version}}" | |
THE_VERSION=${{ env.project_version }} | |
echo "THE_VERSION=${THE_VERSION//-*}" >> $GITHUB_ENV | |
npm --no-git-tag-version version ${THE_VERSION//-*} | |
- name: Release - Allow same version | |
if: ${{ (startsWith(github.ref, 'refs/heads/main')) && (github.event.inputs.allow_same_version == 'true') }} | |
run: | | |
echo "THE_ENV=ops" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=OPS" >> $GITHUB_ENV | |
echo "Modifying version number ${{ env.project_version}}" | |
THE_VERSION=${{ env.project_version }} | |
echo "THE_VERSION=${THE_VERSION//-*}" >> $GITHUB_ENV | |
npm --no-git-tag-version version --allow-same-version ${THE_VERSION//-*} | |
- name: Run Snyk as a blocking step | |
uses: snyk/actions/node@master | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
with: | |
command: test | |
args: > | |
--org=${{ secrets.SNYK_ORG_ID }} | |
--project-name=${{ github.repository }} | |
--severity-threshold=high | |
--fail-on=all | |
- name: Run Snyk on Node | |
uses: snyk/actions/node@master | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
with: | |
command: monitor | |
args: > | |
--org=${{ secrets.SNYK_ORG_ID }} | |
--project-name=${{ github.repository }} | |
- name: Commit Version Bump | |
# If building develop, a release branch, or main then we commit the version bump back to the repo | |
run: | | |
if ${{ github.event.inputs.allow_same_version != 'true' && | |
(github.ref == 'refs/heads/develop' || | |
github.ref == 'refs/heads/main' || | |
startsWith(github.ref, 'refs/heads/release')) }}; then | |
git config --global user.name 'hitide-ui bot' | |
git config --global user.email '[email protected]' | |
git commit -am "/version ${{ env.THE_VERSION }}" | |
git push | |
fi | |
- name: Push Tag | |
if: | | |
github.ref == 'refs/heads/develop' || | |
github.ref == 'refs/heads/main' || | |
startsWith(github.ref, 'refs/heads/release') | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -f -a "${{ env.THE_VERSION }}" -m "Version ${{ env.THE_VERSION }}" | |
git push origin "${{ env.THE_VERSION }}" --force | |
- name: Publish UMM-T with new version | |
uses: podaac/[email protected] | |
if: | | |
github.ref == 'refs/heads/main' || | |
startsWith(github.ref, 'refs/heads/release') | |
with: | |
umm-json: cmr/${{ env.THE_ENV }}_hitide_cmr_umm_t.json | |
provider: 'POCLOUD' | |
env: ${{ env.THE_ENV }} | |
version: ${{ env.THE_VERSION }} | |
timeout: 60 | |
disable_removal: 'true' | |
umm_type: 'umm-t' | |
use_associations: 'false' | |
env: | |
LAUNCHPAD_TOKEN_SIT: ${{secrets.LAUNCHPAD_TOKEN_SIT}} | |
LAUNCHPAD_TOKEN_UAT: ${{secrets.LAUNCHPAD_TOKEN_UAT}} | |
LAUNCHPAD_TOKEN_OPS: ${{secrets.LAUNCHPAD_TOKEN_OPS}} | |
# Setup Node to install and test | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 14 | |
- name: NPM install & NPM Lint | |
run: | | |
npm install | |
npm run build | |
- name: Make Config Files | |
run: | | |
cat ./configs/hitideConfig-${{ env.THE_ENV }}.js > ./dist/hitideConfig.js | |
## Deployment | |
- name: Deploy Env Override | |
if: | | |
github.event.head_commit.message == '/deploy sit' || | |
github.event.head_commit.message == '/deploy uat' | |
run: | | |
message="${{ github.event.head_commit.message }}" | |
trimmed_message=${message:1} # Remove leading slash | |
override_env=$(echo "$trimmed_message" | grep -oE '[^[:space:]]+$') | |
override_env_upper=$(echo "$trimmed_message" | awk '{print toupper($NF)}') | |
echo "THE_ENV=${override_env}" >> $GITHUB_ENV | |
echo "TARGET_ENV_UPPERCASE=${override_env_upper}" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-west-2 | |
role-session-name: GitHubActions | |
aws-access-key-id: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | |
aws-secret-access-key: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | |
- name: Sync S3 | |
if: | | |
github.ref == 'refs/heads/develop' || | |
github.ref == 'refs/heads/main' || | |
startsWith(github.ref, 'refs/heads/release') || | |
github.event.head_commit.message == '/deploy sit' || | |
github.event.head_commit.message == '/deploy uat' | |
run: | |
aws s3 sync ./dist s3://podaac-services-${{ env.THE_ENV }}-hitide --exclude dataset-configs/* --exclude palettes/* --delete |