Skip to content

✨ Add feedback form #150

✨ Add feedback form

✨ Add feedback form #150

Workflow file for this run

name: Build, Release and Publish Website
on:
push:
branches: ["main","production"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: 'Build Website'
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: 'npm'
- name: Restore cache
uses: actions/cache@v4
with:
path: .next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies
run: npm ci
- name: Build website
run: npm run build
env:
BASE_URL: ${{ vars.BASE_URL }}
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID: ${{ vars.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID }}
WSAF_ASSETS_BASE_URL: ${{ vars.WSAF_ASSETS_BASE_URL }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build
path: |
./.next
./public
Dockerfile
release:
name: 'Package and Release'
needs: [build]
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
permissions:
packages: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build
path: ./
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags and labels for Docker release
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy-main:
name: 'Deploy to Main'
needs: [release]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: main
url: https://wsaf24-main.containers.uwcs.co.uk
steps:
- name: Trigger Portainer Deployment
uses: newarifrh/portainer-service-webhook@v1
with:
webhook_url: ${{ secrets.PORTAINER_WEBHOOK_URL }}
deploy-production:
name: 'Deploy to Production'
needs: [release]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/production'
environment:
name: production
url: https://wsaf.org.uk
steps:
- name: Trigger Portainer Deployment
uses: newarifrh/portainer-service-webhook@v1
with:
webhook_url: ${{ secrets.PORTAINER_WEBHOOK_URL }}