Skip to content

Merge pull request #7 from OpenShock/develop #16

Merge pull request #7 from OpenShock/develop

Merge pull request #7 from OpenShock/develop #16

Workflow file for this run

on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, reopened, synchronize]
workflow_dispatch: # Manually invoked by user.
name: ci-master
env:
NODE_VERSION: 21
REGISTRY: ghcr.io
ARTIFACT_NAME: openshock-frontend.zip
IMAGE_NAME: ${{ github.repository_owner }}/frontend
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
shell: bash
run: npm ci
- name: Check
shell: bash
run: npm run check
- name: Install playwright
run: npx playwright install
- name: Test
shell: bash
run: npm test
- name: Build
shell: bash
run: npm run build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
package.json
package-lock.json
build/
retention-days: 1
if-no-files-found: error
containerize:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
Dockerfile
- name: Download internal artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
needs: containerize
if: ${{ github.ref_type == 'branch' && github.ref_protected && github.event_name != 'pull_request' }}
environment: production
steps:
- name: Call deployment webhook
shell: bash
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
curl -X POST -d "" "$WEBHOOK_URL"