Update main.yml #905
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
name: CI | |
on: | |
push: | |
branches: [dev, staging, test, release-**] | |
pull_request: | |
branches: [dev, staging, test, release-**] | |
jobs: | |
Client_Side_Unit_Tests: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js for use with actions | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 22.x | |
# - uses: actions/cache@v1 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-node- | |
- name: update npm | |
run: npm install -g npm | |
- name: npm cache clean | |
run: npm cache clean --force | |
- name: npm ci | |
run: rm -rf node_modules && rm package-lock.json && npm install --verbose | |
- name: log cat | |
run: cat /home/runner/.npm/_logs/* | |
- name: Client Side Unit Tests | |
run: | | |
npm run test | |
# - name: Upload coverage to Codecov | |
# run: bash <(curl -s https://codecov.io/bash) -Z -t ${{ secrets.CODECOV_TOKEN }} -cF javascript | |
Client_Side_Linting: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js for use with actions | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 22.x | |
- name: update npm | |
run: npm install -g npm | |
- name: npm cache clean | |
run: npm cache clean --force | |
# - uses: actions/cache@v1 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-node- | |
- name: npm ci | |
run: | | |
npm ci | |
- name: log cat | |
run: cat /home/runner/.npm/_logs/* | |
- name: Client Side Linting | |
run: | | |
npm run lint | |
Resolve_Image_Tag: | |
runs-on: ubuntu-latest | |
outputs: | |
image_tag: ${{ steps.set_image_tag.outputs.image_tag }} | |
steps: | |
- name: Extract_Branch_Name | |
# Map a step output to a job output | |
shell: bash | |
run: echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Check_Is_Production_Release | |
id: check_is_production_release | |
shell: bash | |
run: | | |
if [ "${{ contains(steps.extract_branch.outputs.branch_name, 'release-') }}" = true ]; then | |
echo "is_production_release=true" >> $GITHUB_OUTPUT; | |
else | |
echo "is_production_release=false" >> $GITHUB_OUTPUT; | |
fi | |
- name: Extract Production Release Version | |
if: ${{ steps.check_is_production_release.outputs.is_production_release == 'true' }} | |
shell: bash | |
run: echo version=$(echo ${{ steps.extract_branch.outputs.branch_name }} | sed -e 's!release-!!') >> $GITHUB_OUTPUT | |
id: extract_version | |
- name: Extract_Image_Tag | |
shell: bash | |
run: | | |
if [ "${{ steps.check_is_production_release.outputs.is_production_release }}" == true ]; then | |
echo "image_tag=${{ steps.extract_version.outputs.version }}" >> $GITHUB_OUTPUT; | |
else | |
echo "image_tag=${{ steps.extract_branch.outputs.branch_name }}" >> $GITHUB_OUTPUT; | |
fi | |
id: set_image_tag | |
Build_Push_Image: | |
needs: | |
- Resolve_Image_Tag | |
- Client_Side_Linting | |
- Client_Side_Unit_Tests | |
runs-on: ubuntu-latest | |
name: Build_Push_Image | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.TAPIS_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.TAPIS_DOCKERHUB_ACCESS_TOKEN }} | |
- name: Build_Tapis_UI_Image | |
run: | | |
BRANCH="${{ needs.Resolve_Image_Tag.outputs.image_tag }}" | |
if [ "${{ contains(needs.Resolve_Image_Tag.outputs.image_tag, 'refs/pull/') }}" == true ]; then | |
BRANCH=dev | |
fi | |
docker build -f Dockerfile -t tapis/tapisui:$BRANCH . | |
- name: Push_All_Tags | |
run: docker push --all-tags tapis/tapisui |