build-and-deploy #275
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
inputs: | |
commit_type: | |
description: 'Commit Type' | |
required: true | |
default: 'refactor' | |
type: choice | |
options: | |
- feat | |
- fix | |
- refactor | |
- chore | |
commit_message: | |
description: 'Commit Message' | |
required: true | |
default: 'update icons' | |
type: string | |
repository_dispatch: | |
types: [build-and-deploy] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
cache: 'npm' | |
node-version-file: '.nvmrc' | |
- run: npm ci | |
- run: npm run build | |
- uses: actions/upload-artifact@v4 | |
if: github.ref == 'refs/heads/main' | |
with: | |
name: showcase | |
path: dist/ | |
showcase: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
env: | |
IMAGE_REPO: ghcr.io/${{ github.repository }}/showcase | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: showcase | |
path: dist/ | |
- name: 'Container: Login to GitHub Container Repository' | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin | |
- name: 'Container: Build image' | |
run: docker build -t $IMAGE_REPO:latest . | |
env: | |
DOCKER_BUILDKIT: 1 | |
- name: 'Container: Publish image' | |
run: docker push $IMAGE_REPO:latest |