Skip to content

Commit

Permalink
Add workflows for ghcr build
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscariremma committed Nov 5, 2023
1 parent e707875 commit 84f4e61
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on: [push, pull_request]

name: "Backend CI"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: npm install
working-directory: backend
- name: Build
run: npm build
working-directory: backend

docker:
runs-on: ubuntu-latest
needs:
- build
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./backend
file: ./backend/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/cthit/bookIT-node-backend:latest
46 changes: 46 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on: [push, pull_request]

name: "Frontend CI"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: npm install
working-directory: frontend
- name: Build
run: npm build
working-directory: frontend

docker:
runs-on: ubuntu-latest
needs:
- build
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./frontend
file: ./frontend/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/cthit/bookIT-node-frontend:latest

0 comments on commit 84f4e61

Please sign in to comment.