Skip to content

Commit

Permalink
feat(ci): add a workflow for building the web component script on mai…
Browse files Browse the repository at this point in the history
…n/releases
  • Loading branch information
jahow committed Apr 21, 2023
1 parent b269b47 commit 2383363
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/webcomponents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Artifacts
run-name: 📦 Generate artifacts for ${{ github.event_name == 'issue_comment' && 'PR' || (github.event_name == 'release' && '🏷' || '🌱') }} ${{github.event_name == 'issue_comment' && github.event.issue.number || github.ref_name}}

# This workflow runs whenever a commit is pushed on main or a release is published
on:
push:
branches:
- main
release:
types: [published]

concurrency:
group: webcomponents-${{ github.ref }}
cancel-in-progress: true

env:
NODE_VERSION: 16.17.0
PUBLISH_BRANCH: wc-dist

jobs:
build-publish-script:
needs: checks
name: Build and publish the gn-wc.js file on the ${{ env.PUBLISH_BRANCH }} branch
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.checks.outputs.ref }}
persist-credentials: false
fetch-depth: 0

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build webcomponents script
run: |
mkdir wc-dist
npm run build:demo
mv dist/demo/webcomponents/gn-wc.js wc-dist
- name: Upload archives to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: wc-dist/gn-wc.js
tag: ${{ github.ref }}
overwrite: true

- name: Publish web component to dist branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
publish_dir: ./wc-dist
publish_branch: ${{ env.PUBLISH_BRANCH }}

0 comments on commit 2383363

Please sign in to comment.