Build Application Docker #22
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
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: false | |
name: Build Application Docker | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: datalens-ui | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
# ? disabled due to a very long ARM build | |
# - uses: docker/setup-qemu-action@v3 | |
# with: | |
# platforms: 'arm64' | |
# - uses: docker/setup-buildx-action@v3 | |
- name: 'Get release build version' | |
run: | | |
BUILD_VERSION=$(jq -r '.version' package.json) | |
COMMIT_NAME=$(git log -n 1 --pretty=format:%s) | |
echo "Release build version: ${BUILD_VERSION}" | |
echo "BUILD_VERSION=$BUILD_VERSION" >> "$GITHUB_ENV" | |
echo "COMMIT_NAME=$COMMIT_NAME" >> "$GITHUB_ENV" | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract tags for Docker | |
id: meta | |
uses: docker/metadata-action@v5.0.0 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ env.BUILD_VERSION }} | |
${{ contains(env.COMMIT_NAME, '[release]') && 'type=raw,value=latest' || '' }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5.0.0 | |
with: | |
build-args: | | |
app_version=${{ env.BUILD_VERSION }} | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# ? disabled due to a very long ARM build | |
# platforms: linux/amd64,linux/arm64 | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe | |
with: | |
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
format: 'template' | |
template: '@/contrib/sarif.tpl' | |
output: 'trivy-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: 'trivy-results.sarif' | |