relink images to main #46
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: Build, Test, Deploy | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*" | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
packages: write ## Github container registry | |
# deployments: write ## Github Pages | |
concurrency: ci-${{ github.ref }} | |
jobs: | |
build-and-test: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest] #, windows-latest ] # windows takes ~3x longer, not worth the cost for larger projects | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Set up Node ⚙ | |
uses: actions/setup-node@v4 | |
- name: Install dependencies & build ⚙️ | |
run: | | |
npm ci | |
npm run build | |
- name: Lint 🔍 | |
run: | | |
npm run lint | |
- name: Test 🔍 | |
run: | | |
npm run test:unit | |
build-and-push-docker: | |
needs: build-and-test | |
if: github.ref == 'refs/heads/{{ github.event.repository.default_branch }}' || startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout 🛎️ | |
# uses: actions/checkout@v3 # incompatible with git lfs cache (https://github.com/actions/checkout/issues/165#issuecomment-940225299) | |
uses: nschloe/action-checkout-with-lfs-cache@v1.2.2 | |
with: | |
exclude: "docs/*" | |
# https://github.com/docker/metadata-action | |
- name: Export Metadata for Docker 🖊️ | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
modischfabrications/cutsolver_frontend | |
ghcr.io/${{ github.repository_owner }}/cutsolver_frontend | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
# Multi-Arch takes over 30min right now, it's not worth it | |
# # https://github.com/docker/setup-qemu-action | |
# - name: Set up QEMU ⚙ | |
# uses: docker/setup-qemu-action@v3 | |
# # https://github.com/docker/setup-buildx-action | |
# - name: Set up Docker Buildx ⚙ | |
# id: buildx | |
# uses: docker/setup-buildx-action@v3 | |
# - name: Report Buildx platforms 🖊️ | |
# run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Login to DH 👤 | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR 👤 | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.com/docker/build-push-action | |
- name: Build and push to DH & GHCR 📦 | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
# platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=user/app:latest | |
cache-to: type=inline | |
- name: Update DH description 🖊️ | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: modischfabrications/cutsolver_frontend | |
readme-filepath: ./README.md | |
short-description: ${{ github.event.repository.description }} |