Workflow file for this run
This file contains hidden or 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: Build and Publish phoenix-websocket | |
# Controls when the workflow will run | |
on: | |
release: | |
types: [released] | |
env: | |
DESIRED_NODE_VERSION: 20 | |
DESIRED_PNPM_VERSION: '8.14.1' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
concurrency: build-and-deploy | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.DESIRED_NODE_VERSION }} | |
- name: PNPM Install | |
run: npm install -g pnpm@${{ env.DESIRED_PNPM_VERSION }} | |
- name: Set sources version | |
run: | | |
VERSION="${{ github.ref }}" | |
if [ -z "$VERSION" ] | |
then | |
echo "Version empty" | |
exit 1 | |
fi | |
if [[ $VERSION == *"/tags/"* ]] | |
then | |
echo "Version is tag." | |
VERSION="${VERSION##*/v}" | |
else | |
echo "Version unexpected format" | |
exit 1 | |
fi | |
echo "Version trimmed to $VERSION" | |
echo "BUILD_VERSION=$VERSION" >> $GITHUB_ENV | |
- uses: falnyr/replace-env-vars-action@master | |
with: | |
filename: package.json | |
- name: Install pnpm dependencies | |
run: | | |
pnpm install --frozen-lockfile | |
- name: Run build | |
run: pnpm run build | |
- uses: actions/setup-node@v3 | |
with: | |
registry-url: 'https://registry.npmjs.org' | |
# NOTE: | |
# By default NPM access tokens expire after a year, and so these will need to be updated when the build starts to fail. | |
- name: Publish | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
- name: Generate docs | |
run: pnpm run docs | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: docs/ | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action | |
with: | |
token: ${{ github.token }} |