Skip to content

Frontend testing by @ericof #53

Frontend testing by @ericof

Frontend testing by @ericof #53

Workflow file for this run

name: Frontend testing
run-name: Frontend testing by @${{ github.actor }}
on:
workflow_dispatch:
push:
paths:
- "frontend/**"
- ".github/workflows/frontend.yml"
env:
NODE_VERSION: "16.x"
VOLTO_VERSION: "16.16.0"
IMAGE_NAME_SUFFIX: frontend
jobs:
meta:
runs-on: ubuntu-latest
outputs:
ENVIRONMENT: ${{ steps.vars.outputs.ENVIRONMENT }}
STACK_NAME: ${{ steps.vars.outputs.STACK_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set Env Vars
id: vars
run: |
ENVIRONMENT=${{ vars.LIVE_ENV }}
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_OUTPUT
echo "STACK_NAME=${ENVIRONMENT//./-}" >> $GITHUB_OUTPUT
codeanalysis:
runs-on: ubuntu-latest
steps:
- name: Main checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'
- name: Linting
run: |
make install-frontend
make lint-frontend
unit:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'
- name: Test
run: |
make install-frontend
make test-frontend-ci
release:
runs-on: ubuntu-latest
needs:
- meta
- codeanalysis
- unit
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ vars.IMAGE_NAME_PREFIX }}-${{ env.IMAGE_NAME_SUFFIX }}
flavor: |
latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
context: frontend/
file: frontend/Dockerfile
build-args: |
VOLTO_VERSION=${{ env.VOLTO_VERSION }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: $${{ steps.meta.outputs.labels }}
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs:
- release
- meta
environment:
name: ${{ needs.meta.outputs.ENVIRONMENT }}
url: ${{ needs.meta.outputs.ENVIRONMENT }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to cluster
uses: kitconcept/docker-stack-deploy@v1.2.0
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
remote_host: ${{ secrets.DEPLOY_HOST }}
remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_private_key: ${{ secrets.DEPLOY_SSH }}
stack_file: devops/stacks/${{ needs.meta.outputs.ENVIRONMENT }}.yml
stack_name: ${{ needs.meta.outputs.STACK_NAME }}
stack_param: ${{ github.ref_name }}
env_file: ${{ secrets.ENV_FILE }}
deploy_timeout: 480