Implement containerisation and automatic image upload #1
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: Build and Push Container Images | |
on: | |
push: | |
branches: | |
- containers | |
pull_request: | |
branches: | |
- containers | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22.8.0 | |
- name: Install dependencies and build frontend | |
run: | | |
cd frontend | |
npm ci | |
npm run build | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN}} | |
# 4. Build and push Frontend Docker image to GHCR | |
- name: Build Frontend Docker image | |
run: | | |
docker build -t ghcr.io/${{ github.repository }}/frontend:latest ./frontend | |
docker push ghcr.io/${{ github.repository }}/frontend:latest | |
# 5. Build and push Backend Docker image to GHCR | |
- name: Build Backend Docker image | |
run: | | |
docker build -t ghcr.io/${{ github.repository }}/backend:latest ./backend | |
docker push ghcr.io/${{ github.repository }}/backend:latest |