diff --git a/.github/workflows/webcomponents.yml b/.github/workflows/webcomponents.yml new file mode 100644 index 0000000000..8c14ac7b9a --- /dev/null +++ b/.github/workflows/webcomponents.yml @@ -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 }}