Skip to content

Merge pull request #64 from TrafeX/dependabot/npm_and_yarn/frontend-n… #145

Merge pull request #64 from TrafeX/dependabot/npm_and_yarn/frontend-n…

Merge pull request #64 from TrafeX/dependabot/npm_and_yarn/frontend-n… #145

Workflow file for this run

name: Test & deploy application
on:
push:
branches: [master]
pull_request:
env:
IMAGE_TAG: ${{ github.sha }}
DOCKER_BUILDKIT: 1
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build images
run: |-
docker pull trafex/clipboard-backend:latest || true
docker pull trafex/clipboard-frontend:latest || true
docker build \
--cache-from=trafex/clipboard-backend:latest \
--target=build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t trafex/clipboard-backend:ci \
backend/
docker build \
--cache-from=trafex/clipboard-frontend:latest \
--target=build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t trafex/clipboard-frontend:ci \
frontend-ng/
docker build \
--cache-from=trafex/clipboard-backend:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t trafex/clipboard-backend:$IMAGE_TAG \
backend/
- name: Test images
run: |-
docker run --rm trafex/clipboard-frontend:ci npm run lint
docker run --rm trafex/clipboard-backend:ci npm run eslint
- name: Run Trivy vulnerability scanner on backend
uses: aquasecurity/trivy-action@master
with:
image-ref: "trafex/clipboard-backend:${{ env.IMAGE_TAG }}"
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
- name: Push images
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |-
docker tag trafex/clipboard-backend:$IMAGE_TAG trafex/clipboard-backend:latest
docker push trafex/clipboard-backend:latest
docker tag trafex/clipboard-frontend:ci trafex/clipboard-frontend:latest
docker push trafex/clipboard-frontend:latest
- name: Deploy frontend to production
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: |
npm install --global vercel@latest
cd frontend-ng/
vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}