Skip to content

feedback with attachment (#263) #334

feedback with attachment (#263)

feedback with attachment (#263) #334

Workflow file for this run

name: Web
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
IS_BUILD_SERVER: true # Needed by spa testing
# SENTRY_LOG_LEVEL: "debug"
on:
push:
tags:
- 'v*.*.*'
branches:
- main
paths:
- 'src/NuGetTrends.Web/**'
- 'src/NuGetTrends.Data/**'
- 'src/Directory.Build.props'
- '**/web-workflow.yml'
pull_request:
paths:
- 'src/NuGetTrends.Web/**'
- 'src/NuGetTrends.Data/**'
- 'src/Directory.Build.props'
- '**/web-workflow.yml'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
DOTNET_MULTILEVEL_LOOKUP: 1
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Prepare Docker
id: docker-prep
run: |
DOCKER_IMAGE=nugettrends/nugettrends.web
VERSION=noop
ENVIRONMENT=test
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
ENVIRONMENT=prod
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=environment::${ENVIRONMENT}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker values debug
run: |
echo ${{ steps.docker-prep.outputs.environment }}
echo ${{ steps.docker-prep.outputs.version }}
echo ${{ steps.docker-prep.outputs.tags }}
echo ${{ steps.docker-prep.outputs.created }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: src/NuGetTrends.Web/Portal/package-lock.json
- name: Install Angular CLI
run: npm install -g @angular/cli@17.1.3
- name: Test/print Angular CLI version
run: ng version
- name: 'Install SPA packages'
run: npm install
working-directory: src/NuGetTrends.Web/Portal
# TODO: Enable again when we migrate to ESLint
# - name: 'SPA lint'
# run: yarn run lint
# working-directory: src/NuGetTrends.Web/Portal
- name: 'SPA test'
run: npm run test-cc
working-directory: src/NuGetTrends.Web/Portal
- name: 'SPA prod build'
# Angular runs a prod build by default
run: npm run build
working-directory: src/NuGetTrends.Web/Portal
- name: Replace SPA path on coverage file (Hack codecov) # https://community.codecov.io/t/looking-for-assistance-with-path-fixing/1669/9
run: sed -i 's/SF:/SF:src\/NuGetTrends.Web\/Portal\//g' src/NuGetTrends.Web/Portal/coverage/lcov.info
- name: Upload SPA coverage report to Codecov
uses: codecov/codecov-action@v3
- name: Web Build
run: dotnet build -c Release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
working-directory: src/NuGetTrends.Web/
- name: Web Publish
run: dotnet publish -c Release -o publish --no-build
working-directory: src/NuGetTrends.Web/
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: ./src/NuGetTrends.Web
file: ./src/NuGetTrends.Web/Dockerfile
build-args: |
ENVIRONMENT=${{ steps.docker-prep.outputs.environment }}
VERSION=${{ steps.docker-prep.outputs.version }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-prep.outputs.tags }}
labels: |
org.opencontainers.image.created=${{ steps.docker-prep.outputs.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.docker-prep.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}