Skip to content

drinkice-site

drinkice-site #1

Workflow file for this run

name: drinkice-site
on:
workflow_dispatch:
push:
paths:
- 'site/**'
env:
PROJECT_PATH: 'site'
IMAGE_NAME: 'drinkice-site'
jobs:
drinkice-site-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.output
.nuxt
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('.output') }}
restore-keys: |
${{ runner.os }}-nuxt-build-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build
run: ${{ steps.detect-package-manager.outputs.manager }} run build
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v2
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Build and push docker image'
uses: docker/build-push-action@v5
with:
context: ${{ env.PROJECT_PATH }}
file: ${{ env.PROJECT_PATH }}/Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME }}:latest