feat: add dummy ci/cd #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Next.js CI/CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: Build Application | |
runs-on: self-hosted | |
steps: | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.bun/install/cache | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('bun.lockb') }}- | |
- uses: actions/checkout@v4 | |
- run: bun install | |
- run: bun run build | |
unit-tests: | |
needs: ['build'] | |
name: Unit Testing | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- run: bun install | |
- run: bun test | |
build-and-push-image: | |
name: Build and Push Docker Image | |
runs-on: self-hosted | |
needs: ['unit-tests'] | |
# Modifies the default permissions granted to the GITHUB_TOKEN | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Console log meta steps.meta.outputs.labels | |
run: echo "${{ steps.meta.outputs.labels }}" | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
name: deploy-to-dev | |
environment: Development | |
runs-on: self-hosted | |
needs: ['build-and-push-image'] | |
steps: | |
- run: echo "Deploying to Development" | |