Skip to content

Merge pull request #80 from OpenShock/dependabot/npm_and_yarn/bootstr… #90

Merge pull request #80 from OpenShock/dependabot/npm_and_yarn/bootstr…

Merge pull request #80 from OpenShock/dependabot/npm_and_yarn/bootstr… #90

Workflow file for this run

on:
push:
branches:
- develop
pull_request:
branches:
- develop
types: [opened, reopened, synchronize]
name: ci-develop
# REGISTRY and IMAGE_NAME are for building and tagging the container.
# TARGET_ENV is used by Webpack to determine the build target.
env:
REGISTRY: ghcr.io
ARTIFACT_NAME: openshock-webui.zip
IMAGE_NAME: ${{ github.repository_owner }}/webui
TARGET_ENV: container
NODE_ENV: development
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 17.x
- uses: actions/cache@v3
with:
path: |
~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: npm install
- name: Build
run: npm run build --if-present
- name: Compress internal artifacts
run: |
cd dist
zip -r ${{ env.ARTIFACT_NAME }} .
cd ..
mv dist/${{ env.ARTIFACT_NAME }} .
- name: Upload internal artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }}
retention-days: 1
containerize:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
Dockerfile
- name: Download internal artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Extract artifacts
run: unzip ${{ env.ARTIFACT_NAME }} -d dist
- 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: Find latest tag
uses: oprypin/find-latest-tag@v1
id: latest-tag
with:
repository: ${{ github.repository }}
regex: '^[0-9]+.[0-9]+.[0-9]+$'
releases-only: false
- 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=raw,value=latest,enable=${{ steps.latest-tag.outputs.tag == github.ref_name }}
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: staging
steps:
- name: Call deployment webhook
shell: bash
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
curl -X POST -d "" "$WEBHOOK_URL"