Skip to content

Build

Build #7

Workflow file for this run

name: "Build"
on:
push:
tags:
- '**'
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
build_and_publish:
runs-on: ubuntu-latest
env:
APP_NAME: midaz-console
DOCKERHUB_ORG: lerianstudio
name: Build And Publish Docker Image to Midaz
steps:
- name: Set up GitHub token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch,suffix=-${{ github.sha }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
load: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:latest
build-args: |
GITHUB_TOKEN=${{ steps.app-token.outputs.token }}
- name: Extract tag name
shell: bash
run: echo "tag=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
id: extract_tag
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:${{ steps.extract_tag.outputs.tag }}'
format: 'table'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
exit-code: '1'
- name: Push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}