62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| name: Build the portfolio website
 | |
| on:
 | |
|   workflow_dispatch:
 | |
|   push:
 | |
|     branches:
 | |
|       - master
 | |
|   pull_request:
 | |
|     branches:
 | |
|       - master
 | |
| 
 | |
| jobs:
 | |
|   build-portfolio-website:
 | |
|     runs-on: ubuntu-latest
 | |
|     steps:
 | |
|       - name: Checkout code
 | |
|         uses: actions/checkout@v2
 | |
| 
 | |
|       - name: Set up Node.js
 | |
|         uses: actions/setup-node@v2
 | |
|         with:
 | |
|           node-version: "20"
 | |
| 
 | |
|       - name: Install dependencies
 | |
|         run: cd frontend && npm install
 | |
| 
 | |
|       - name: Build the project
 | |
|         run: cd frontend && npm run build
 | |
| 
 | |
|   build-and-release-image:
 | |
|     runs-on: ubuntu-latest
 | |
|     needs: build-portfolio-website
 | |
|     if: success()
 | |
|     steps:
 | |
|       - name: Install Buildah
 | |
|         run: |
 | |
|           apt-get update
 | |
|           apt-get install -y buildah
 | |
| 
 | |
|       - name: Checkout
 | |
|         uses: actions/checkout@v4
 | |
|         with:
 | |
|           fetch-depth: 0 # all history for all branches and tags
 | |
| 
 | |
|       - name: Set up Docker Buildx
 | |
|         uses: docker/setup-buildx-action@v3
 | |
|         with:
 | |
|           driver: docker-container
 | |
| 
 | |
|       - name: Login to Docker registry
 | |
|         env:
 | |
|           REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
 | |
|           USERNAME: ${{ secrets.DOCKER_USERNAME }}
 | |
|           PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
 | |
|         run: |
 | |
|           buildah login -u "$USERNAME" -p "$PASSWORD" "$REGISTRY"
 | |
| 
 | |
|       - name: Build Image with Buildah
 | |
|         env:
 | |
|           REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
 | |
|         run: |
 | |
|           buildah bud -t "$REGISTRY"/my-portfolio-app:latest .
 |