Skip to content

Merge pull request #8 from DaRichardX/chore/hero-page #26

Merge pull request #8 from DaRichardX/chore/hero-page

Merge pull request #8 from DaRichardX/chore/hero-page #26

Workflow file for this run

name: Build and Deploy
on:
push:
branches: ["main"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: "darichardx/educourse"
IS_STATIC_APP: true
jobs:
amd64:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
# Step 1: Checkout repository
- uses: actions/checkout@v3
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18 # Use the Node.js version required by your Next.js app
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Cache dependencies
- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
#this is fucking disgusting. UGHHHH
#like srsly? what the fucking devops is this?? wtf next.js???
#explaination: public env only public if i do it at build time, like srsly wtf???
- name: 'Create env file'
run: |
touch .env
echo NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.FIREBASE_API_KEY }} >> .env
echo NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.FIREBASE_AUTH_DOMAIN }} >> .env
echo NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.FIREBASE_PROJECT_ID }} >> .env
echo NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.FIREBASE_STORAGE_BUCKET }} >> .env
echo NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.FIREBASE_MESSAGING_SENDER_ID }} >> .env
echo NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.FIREBASE_APP_ID }} >> .env
cat .env
# Step 4: Build the Next.js app
- name: Build the Next.js app
run: npm run build
# Step 5: Export the Next.js app (optional for static apps)
#- name: Export static Next.js app
# if: ${{ env.IS_STATIC_APP == 'true' }}
# run: npm run export
# Step 6: Build and push Docker image
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Step 7: Deploy to Coolify
- name: Deploy to Coolify
run: |
curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' \
--header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'