added a component #2
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: Frontend Workflow | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- 'v*' | |
paths: | |
- 'PackIt-frontend/**' | |
- '.github/workflows/frontend.yml' | |
pull_request: | |
branches: | |
- '**' | |
paths: | |
- 'PackIt-frontend/**' | |
- '.github/workflows/frontend.yml' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}-frontend | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./PackIt-frontend | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build | |
- name: Upload artifact to enable deployment | |
uses: actions/upload-artifact@v2 | |
with: | |
name: production-files | |
path: PackIt-frontend/dist | |
deploy: | |
permissions: | |
pages: write | |
contents: write | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download production artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: production-files | |
paths: dist | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/action-gh-pages@v3 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: dist | |
docker-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
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 docker registery | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: string | |
uses: AsZc/change-string-case-action@v6 | |
with: | |
string: ${{ env.IMAGE_NAME }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }} | |
# build and push | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
if: github.event_name != 'pull_request' | |
with: | |
context: ./PackIt-frontend | |
file: ./PackIt-frontend | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |