Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR preview
name: Deploy preview

on:
pull_request:
Expand All @@ -11,7 +11,7 @@ env:
MAX_QUERY_LENGTH: 500

jobs:
preview:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Deploy release

on:
release:
Expand All @@ -14,7 +14,25 @@ env:
PREVIEW_WIDGET_URL: https://cdn.croct.io/js/v1/lib/plug/widget-${{ github.ref_name }}.html

jobs:
deploy-library:
deploy:
uses: croct-tech/shared-public-configs/.github/workflows/publish-public-npm-package.yml@master
with:
prepare-script: >-
cp LICENSE README.md build/ &&
cd build &&
find . -type f -path '*/*\.js.map' -exec sed -i -e "s~../src~src~" {} + &&
sed -i -e "s~\"version\": \"0.0.0-dev\"~\"version\": \"${GITHUB_REF##*/}\"~" package.json &&
sed -i -e "s~<@cdnUrl@>~${CDN_URL}~" constants.* &&
sed -i -e "s~<@playgroundOrigin@>~${PLAYGROUND_ORIGIN}~" constants.* &&
sed -i -e "s~<@playgroundConnectUrl@>~${PLAYGROUND_CONNECT_URL}~" constants.* &&
sed -i -e "s~<@previewWidgetOrigin@>~${PREVIEW_WIDGET_ORIGIN}~" constants.* &&
sed -i -e "s~<@previewWidgetUrl@>~${PREVIEW_WIDGET_URL}~" constants.*
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

cdn:
if: ${{ !github.event.release.prerelease }}
needs: deploy
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
Expand All @@ -37,44 +55,9 @@ jobs:

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |-
npm ci
rm -rf ~/.npmrc

- name: Build package
run: |-
npm run build

- name: Prepare release
run: |-
cp LICENSE README.md build/
cd build
find . -type f -path '*/*\.js.map' -exec sed -i -e "s~../src~src~" {} +
sed -i -e "s~\"version\": \"0.0.0-dev\"~\"version\": \"${GITHUB_REF##*/}\"~" package.json
sed -i -e "s~<@cdnUrl@>~${CDN_URL}~" constants.*
sed -i -e "s~<@playgroundOrigin@>~${PLAYGROUND_ORIGIN}~" constants.*
sed -i -e "s~<@playgroundConnectUrl@>~${PLAYGROUND_CONNECT_URL}~" constants.*
sed -i -e "s~<@previewWidgetOrigin@>~${PREVIEW_WIDGET_ORIGIN}~" constants.*
sed -i -e "s~<@previewWidgetUrl@>~${PREVIEW_WIDGET_URL}~" constants.*

- name: Publish pre-release to NPM
if: ${{ github.event.release.prerelease }}
run: |-
cd build
npm publish --access public --tag next
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish release to NPM
if: ${{ !github.event.release.prerelease }}
run: |-
cd build
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm ci

- name: Bundle package
if: ${{ !github.event.release.prerelease }}
run: |-
rm -rf build
npm run bundle -- --config-cdn-url=${CDN_URL} \
Expand All @@ -85,7 +68,6 @@ jobs:

- id: 'auth'
name: 'Authenticate to Google Cloud'
if: ${{ !github.event.release.prerelease }}
uses: 'google-github-actions/auth@v3'
with:
workload_identity_provider: '${{ secrets.GCLOUD_WORKLOAD_IDENTITY }}'
Expand All @@ -95,14 +77,13 @@ jobs:
uses: google-github-actions/setup-gcloud@v3

- name: Deploy to GCS
if: ${{ !github.event.release.prerelease }}
env:
GCLOUD_BUCKET: ${{ secrets.GCLOUD_BUCKET }}
run: |-
gsutil -m cp build/plug.min.js "gs://${GCLOUD_BUCKET}/js/v1/lib/plug.js"
gsutil -m setmeta -h "Cache-Control: public, max-age=3600" "gs://${GCLOUD_BUCKET}/js/v1/lib/plug.js"

deploy-preview-widget:
preview-widget:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
Expand Down
103 changes: 0 additions & 103 deletions .github/workflows/library-validations.yaml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/validate-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Validate branch

on:
push:
tags-ignore:
- '**'
branches:
- master
pull_request:
types:
- synchronize
- opened

jobs:
validate:
uses: croct-tech/shared-public-configs/.github/workflows/javascript-validations.yml@master
with:
run-security: true
use-private-registry: false
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Label requirements
name: Validate labels
on:
pull_request:
types:
Expand All @@ -9,7 +9,7 @@ on:
- unlabeled

jobs:
check-labels:
validate:
name: Check labels
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Preview validations
name: Validate preview

on:
push:
Expand All @@ -12,7 +12,7 @@ on:
- opened

jobs:
validate:
type-check:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -38,7 +38,7 @@ jobs:
run: npm run validate

lint:
needs: [ validate ]
needs: [ type-check ]
runs-on: ubuntu-latest
defaults:
run:
Expand Down
Loading