Skip to content

Deploy

Deploy #268

Workflow file for this run

name: Deploy
on:
schedule:
- cron: '0 0 * * 1'
push:
branches:
- 'master'
paths:
- 'scss/**'
- 'views/**'
- '*'
- '.github/workflows/deploy.yml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_SOURCE: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
environment: default
permissions:
contents: write
packages: write
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build Styles
run: npm run build
- uses: actions/setup-go@v5
with:
go-version: '^1.21.1'
- name: Build Backend
run: GOOS=linux go build
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: anothrNick/[email protected]
id: bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: patch
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.bump.outputs.new_tag }}
type=semver,pattern={{major}},value=${{ steps.bump.outputs.new_tag }}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
format: 'github'
output: 'dependency-results.sbom.json'
image-ref: ${{ env.IMAGE_SOURCE }}
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
github-pat: ${{ secrets.GITHUB_TOKEN }}
cleanup:
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: video-gallery
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: true