40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
name: Deploy
|
|
|
|
# Deploy on every push to master (and allow manual runs from the Actions tab).
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
# `docker` runner => node:22-bookworm image WITH the Docker socket available,
|
|
# so `docker build` / `docker run` control the host's Docker daemon.
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# Build the site into an nginx image (see Dockerfile). Tagged with the
|
|
# commit SHA for traceability, plus :latest for convenience.
|
|
- name: Build image
|
|
run: |
|
|
docker build -t altricade-portfolio:${{ github.sha }} -t altricade-portfolio:latest .
|
|
|
|
# Replace the running container with the freshly built image.
|
|
# -p 8080:80 publishes the container on host port 8080.
|
|
# Point Nginx Proxy Manager's proxy host at: <server-ip>:8080
|
|
# (Or, if NPM runs in Docker, put this container on NPM's network and
|
|
# forward to altricade-portfolio:80 instead — see note below.)
|
|
- name: Deploy container
|
|
run: |
|
|
docker rm -f altricade-portfolio 2>/dev/null || true
|
|
docker run -d \
|
|
--name altricade-portfolio \
|
|
--restart unless-stopped \
|
|
-p 8080:80 \
|
|
altricade-portfolio:latest
|
|
|
|
# Free disk on the shared runner by dropping old, untagged images.
|
|
- name: Prune old images
|
|
run: docker image prune -f
|