build: use mint to minify container images #286
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
name: Continuous Integration | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
inputs: | |
commit_type: | |
description: 'Commit Type' | |
required: true | |
default: 'refactor' | |
type: choice | |
options: | |
- feat | |
- fix | |
- refactor | |
- chore | |
commit_message: | |
description: 'Commit Message' | |
required: true | |
default: 'update icons' | |
type: string | |
repository_dispatch: | |
types: [build-and-deploy] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
cache: 'npm' | |
node-version-file: '.nvmrc' | |
- run: npm ci | |
- run: npm run build | |
- uses: actions/upload-artifact@v4 | |
if: github.ref == 'refs/heads/main' | |
with: | |
name: showcase | |
path: dist/ | |
showcase: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
env: | |
IMAGE_REPO: ghcr.io/${{ github.repository }}/showcase | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: showcase | |
path: dist/ | |
- uses: ./.github/actions/setup-mint | |
- name: 'Container: Build and push image' | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin | |
docker build -t $IMAGE_REPO:latest-fat . | |
mint slim \ | |
--target $IMAGE_REPO:latest-fat \ | |
--tag $IMAGE_REPO:latest \ | |
--preserve-path /usr/share/nginx/html | |
docker push $IMAGE_REPO:latest | |
env: | |
DOCKER_BUILDKIT: 1 |