44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
name: Deploy Homepage
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: package.json
|
|
- name: Install
|
|
run: npm install
|
|
|
|
# build/standalone is the output directory for the Next.js app
|
|
# now we want to deploy a container with the built app
|
|
- name: Build Docker image
|
|
run: docker build -t homepage:latest .
|
|
- name: Stop and remove existing container
|
|
run: |
|
|
docker stop website-server || true
|
|
docker rm website-server || true
|
|
- name: Wait for any monitoring services to recognize the stopped container
|
|
# sleep for 10 seconds to ensure the container is fully stopped
|
|
run: sleep 10
|
|
- name: Run Docker container
|
|
run: |
|
|
docker run -d \
|
|
--expose=80 \
|
|
--network=web \
|
|
--name website-server \
|
|
homepage:latest
|
|
- name: Clean up Docker image
|
|
run: docker rmi homepage:latest || true
|
|
- name: Clean up unused Docker resources
|
|
run: docker system prune -f --volumes || true
|
|
- name: Notify deployment success
|
|
run: echo "Deployment successful!"
|
|
|