.github/workflows/publish.yml
name: Publish
on:
push:
branches: [main]
tags: ["v*"]
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
publish-docker-images:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up context
id: project_context
uses: FranzDiebold/github-env-vars-action@v2.7.0
- name: Extract metadata (tags, labels) for Docker
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }},${{ github.repository }}
tags: |
type=raw,value=nightly
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.vendor=OKP4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_REGISTRY_ID }}
password: ${{ secrets.DOCKER_HUB_REGISTRY_TOKEN }}
- name: Build and publish image(s)
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
publish-npm-package:
runs-on: ubuntu-22.04
strategy:
matrix:
registry:
- url: "https://npm.pkg.github.com"
auth-token-secret: NPM_REGISTRY_TOKEN
- url: "https://registry.npmjs.org"
auth-token-secret: NPM_PUBLIC_REGISTRY_TOKEN
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup node environment (for publishing)
uses: actions/setup-node@v4
with:
node-version: 16.14.0
registry-url: ${{ matrix.registry.url }}
scope: "@okp4"
- name: Publish package
run: |
yarn && yarn build
DATE=$(date +%Y%m%d%H%M%S)
publish=(yarn publish --access=public --no-git-tag-version --non-interactive)
if [[ $GITHUB_REF == refs/tags/v* ]]; then
publish+=(--tag latest)
else
publish+=(--prerelease --preid next.$DATE --tag next)
fi
echo "🚀 Publishing npm package with following command line: ${publish[@]}"
"${publish[@]}"
env:
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.auth-token-secret] }}
publish-storybook:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup node environment (for publishing)
uses: actions/setup-node@v4
with:
node-version: 16.14.0
registry-url: "https://npm.pkg.github.com"
scope: "@okp4"
- name: Build storybook
run: |
yarn
yarn build-storybook
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.OKP4_TOKEN }}
publish_dir: ./dist
commit_message: |
feat: update storybook site (auto)
cname: ui.okp4.space