✨ : preload the video #26
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
name: Publish Package | |
# Ref: https://github.com/azu/lerna-monorepo-github-actions-release/blob/master/.github/workflows/publish.yml | |
on: | |
push: | |
branches: [main, master] | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
packages: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Required to retrieve git history | |
- name: Set up Volta | |
uses: volta-cli/action@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16.10.0' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: 💿 Install packages | |
run: | | |
npm config set //npm.pkg.github.com/:_authToken=\${GITHUB_TOKEN} | |
yarn install --frozen-lockfile | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: 🏗️ Build packages | |
run: yarn clean && yarn build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Define ${CURRENT_VERSION} | |
- name: Set Current Version | |
shell: bash -ex {0} | |
run: | | |
CURRENT_VERSION=$(node -p 'require("./lerna.json").version') | |
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV | |
- name: Tag Check | |
id: tag_check | |
shell: bash -ex {0} | |
run: | | |
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}" | |
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ | |
-H "Authorization: token ${GITHUB_TOKEN}") | |
if [ "$http_status_code" -ne "404" ] ; then | |
echo "::set-output name=exists_tag::true" | |
else | |
echo "::set-output name=exists_tag::false" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create_release | |
if: steps.tag_check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
with: | |
tag_name: v${{ env.CURRENT_VERSION }} | |
# Copy Pull Request's tile and body to Release Note | |
release_name: ${{ github.event.pull_request.title }} | |
body: | | |
${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
- name: 📢 Publish as NPM packages | |
run: | | |
git stash | |
npm config set //registry.npmjs.org/:_authToken=\${NPM_TOKEN} | |
yarn release | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
GH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 📄Upload built docs | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./apps/docs/out | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: 📄Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |