MORE-721: Linter Fix #572
Workflow file for this run
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: Test, Build and Publish | |
on: | |
push: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository_owner }}/more-study-manager-frontend | |
jobs: | |
test: | |
name: "Run Tests" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
- name: Cache NPM | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Dependencies | |
run: npm ci | |
- name: Run linting | |
run: npm run lint | |
- name: 3rd-Party Licenses | |
run: | | |
mkdir -p target/ | |
npm --silent run license:list > target/THIRD_PARTY.txt | |
cat target/THIRD_PARTY.txt | |
- name: Upload License List | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 3rd Party Licenses | |
path: "target/THIRD_PARTY.txt" | |
- name: Check licenses | |
run: npm run license:check | |
# - name: Run tests | |
# run: npm run test:unit:once | |
# | |
# - name: Upload Test Results | |
# if: always() | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: Test Results | |
# path: "target/testResults.xml" | |
- name: Run build | |
run: npm run package | |
build-and-push-image: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
if: (github.ref_type == 'branch' && github.ref_name == 'main') || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) | |
needs: | |
- test | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4.3.0 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
event_file: | |
name: "Event File" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Event File | |
path: ${{ github.event_path }} |