-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add a workflow for building the web component script on mai…
…n/releases
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |